#!/usr/bin/env python # -*- coding: utf-8 -*- import gtk, pygtk, os from optparse import OptionParser from DrPrintGui.MainWin import MainWin from DrPrintBackend import Backend if __name__ == "__main__": ## Analyze comand line options usage = "usage: %prog [options] [file]" parser = OptionParser(usage=usage) parser.add_option("-u", "--user", dest="user",default=None, help = "set username to use for the ssh connection", metavar="user") (option, args) = parser.parse_args() if len(args) > 0: filename = args[0] else: filename = None # The backend doing network work. backend = Backend() # If no user is provided on command line, # check if a file .drprint exists in the # home directory configuration_file = os.path.expanduser("~/.drprint") if option.user is None and os.path.exists(configuration_file): with open(configuration_file, "r") as handle: content = handle.read() user = content.strip() else: user = option.user # ...and the Gtk main window. mw = MainWin(backend = backend, user = user, filename = filename) ## Show all :) mw.show() ## ..and let's go! gtk.main()