1"""Code for the B{0desktop} command.""" 2 3# Copyright (C) 2009, Thomas Leonard 4# See the README file for details, or visit http://0install.net. 5 6from__future__importprint_function 7 8fromzeroinstallimport_,logger 9importsys10fromoptparseimportOptionParser11importlogging12
14"""Implements the logic of the 0desktop command.15 @param command_args: the command-line arguments"""16parser=OptionParser(usage=_("usage: %prog [options] [URI]"))17parser.add_option("-m","--manage",help=_("manage added applications"),action='store_true')18parser.add_option("-v","--verbose",help=_("more verbose output"),action='count')19parser.add_option("-V","--version",help=_("display version information"),action='store_true')2021(options,args)=parser.parse_args(command_args)2223ifoptions.verbose:24ifoptions.verbose==1:25logger.setLevel(logging.INFO)26else:27logger.setLevel(logging.DEBUG)28hdlr=logging.StreamHandler()29fmt=logging.Formatter("%(levelname)s:%(message)s")30hdlr.setFormatter(fmt)31logger.addHandler(hdlr)3233ifoptions.version:34importzeroinstall35print("0desktop (zero-install) "+zeroinstall.version)36print("Copyright (C) 2013 Thomas Leonard")37print(_("This program comes with ABSOLUTELY NO WARRANTY,"38"\nto the extent permitted by law."39"\nYou may redistribute copies of this program"40"\nunder the terms of the GNU Lesser General Public License."41"\nFor more information about these matters, see the file named COPYING."))42sys.exit(0)4344ifnotargs:45interface_uri=None46eliflen(args)==1:47interface_uri=args[0]48else:49parser.print_help()50sys.exit(1)5152ifsys.version_info[0]<3:53importpygtk54pygtk.require('2.0')55else:56fromzeroinstall.gtkuiimportpygtkcompat57pygtkcompat.enable()58pygtkcompat.enable_gtk(version='3.0')59importgtk6061ifoptions.manage:62fromzeroinstall.gtkui.applistboximportAppListBox,AppList63fromzeroinstall.injector.iface_cacheimportiface_cache64box=AppListBox(iface_cache,AppList())65else:66fromzeroinstall.gtkui.addboximportAddBox67box=AddBox(interface_uri)6869box.window.connect('destroy',gtk.main_quit)70box.window.show()71gtk.main()