Пример #1
0
 def __init__(self):
     parser = OptionParser()
     parser.add_option('-d', '--debug', dest='debug', action='store_true',
         help='Debug Mode', default=False)
     parser.add_option('-i', '--interface', dest='interface',
         help='Select interface to use. (cmd|gtk)', default='gtk')
     parser.add_option('-c', '--clean', dest='clean', action='store_true',
         help='Clean all bytecodes', default=False)
     parser.add_option('--test', dest='test', action='store_true',
         help='Test mode. Only load timeline', default=False)
     
     (options, _) = parser.parse_args()
     
     self.config = None
     self.global_cfg = ConfigApp()
     self.profile = None
     self.remember = False
     self.testmode = options.test
     self.httpserv = None
     self.api = None
     
     if options.debug: 
         logging.basicConfig(level=logging.DEBUG)
     else:
         logging.basicConfig(level=logging.INFO)
     self.log = logging.getLogger('Controller')
     
     if options.clean:
         self.__clean()
         self.signout()
         
     self.interface = options.interface
     #if options.interface == 'gtk2':
     #    self.ui = gtk2_ui_main.Main(self)
     if options.interface == 'gtk+':
         self.ui = _GTK(self, extend=True)
     elif options.interface == 'gtk':
         self.ui = _GTK(self)
     else:
         print 'No existe tal interfaz. Saliendo...'
         sys.exit(-1)
     
     self.httpserv = HTTPServices()
     self.api = TurpialAPI()
     
     self.log.debug('Iniciando Turpial')
     self.httpserv.start()
     self.api.start()
     self.api.change_api_url(self.global_cfg.read('Proxy', 'url'))
     
     if self.testmode:
         self.log.debug('Modo Pruebas Activado')
         
     self.ui.show_login(self.global_cfg)
     self.ui.main_loop()
Пример #2
0
    def __init__(self):
        ui_avail = "("
        for ui in INTERFACES:
            ui_avail += ui + "|"
        ui_avail = ui_avail[:-1] + ")"
        default_ui = INTERFACES[1] if len(INTERFACES) > 1 else ""

        parser = OptionParser()
        parser.add_option(
            "-d",
            "--debug",
            dest="debug",
            action="store_true",
            help="show debug info in shell during execution",
            default=False,
        )
        parser.add_option(
            "-i", "--interface", dest="interface", help="select interface to use %s" % ui_avail, default=default_ui
        )
        parser.add_option("-c", "--clean", dest="clean", action="store_true", help="clean all bytecodes", default=False)
        parser.add_option(
            "-s", "--save-credentials", dest="save", action="store_true", help="save user credentials", default=False
        )
        parser.add_option(
            "--version", dest="version", action="store_true", help="show the version of Turpial and exit", default=False
        )
        parser.add_option(
            "--test", dest="test", action="store_true", help="only load timeline and friends", default=False
        )
        parser.add_option(
            "--no-sound", dest="no_sound", action="store_true", help="disable the sounds module", default=False
        )
        parser.add_option(
            "--no-notif", dest="no_notif", action="store_true", help="disable the notifications module", default=False
        )

        (options, args) = parser.parse_args()

        self.config = None
        self.global_cfg = ConfigApp()
        self.protocol_cfg = {}
        self.profile = None
        self.testmode = options.test
        self.interface = options.interface
        self.no_sound = options.no_sound
        self.no_notif = options.no_notif
        self.httpserv = None
        self.api = None
        self.version = self.global_cfg.read("App", "version")

        for p in PROTOCOLS:
            self.protocol_cfg[p] = ConfigProtocol(p)

        if options.debug or options.clean:
            logging.basicConfig(level=logging.DEBUG)
        else:
            logging.basicConfig(level=logging.INFO)
        self.log = logging.getLogger("Controller")

        if options.clean:
            self.__clean()
            sys.exit(0)

        if options.version:
            print "Turpial v%s" % self.version
            print "Python v%X" % sys.hexversion
            sys.exit(0)

        if options.save:
            try:
                self.__save_credentials()
            except KeyboardInterrupt:
                self.log.debug("Interceptado Keyboard Interrupt")
            sys.exit(0)

        self.interface = options.interface
        if options.interface == "gtk+" and ("gtk+" in INTERFACES):
            self.ui = _GTK(self, extend=True)
        elif options.interface == "gtk" and ("gtk" in INTERFACES):
            self.ui = _GTK(self)
        elif options.interface == "cmd" and ("cmd" in INTERFACES):
            self.ui = _CMD(self, args)
        else:
            print "No existe una interfaz válida. Las interfaces válidas son: %s" % INTERFACES
            print "Saliendo..."
            sys.exit(-1)

        self.httpserv = HTTPServices()
        self.api = TurpialAPI()

        self.log.debug("Iniciando Turpial v%s" % self.version)
        if self.interface != "cmd":
            self.httpserv.start()
        self.api.start()
        self.api.change_api_url(self.global_cfg.read("Proxy", "url"))

        if self.testmode:
            self.log.debug("Modo Pruebas Activado")

        self.ui.show_login()
        try:
            self.ui.main_loop()
        except KeyboardInterrupt:
            self.log.debug("Interceptado Keyboard Interrupt")
            self.ui.main_quit()
Пример #3
0
 def __init__(self):
     ui_avail = '('
     for ui in INTERFACES:
         ui_avail += ui + '|'
     ui_avail = ui_avail[:-1] + ')'
     default_ui = INTERFACES[1] if len(INTERFACES) > 1 else ''
     
     parser = OptionParser()
     parser.add_option('-d', '--debug', dest='debug', action='store_true',
         help='show debug info in shell during execution', default=False)
     parser.add_option('-i', '--interface', dest='interface',
         help='select interface to use %s' % ui_avail, default=default_ui)
     parser.add_option('-c', '--clean', dest='clean', action='store_true',
         help='clean all bytecodes', default=False)
     parser.add_option('-s', '--save-credentials', dest='save', action='store_true',
         help='save user credentials', default=False)
     parser.add_option('--version', dest='version', action='store_true',
         help='show the version of Turpial and exit', default=False)
     parser.add_option('--test', dest='test', action='store_true',
         help='only load timeline and friends', default=False)
     parser.add_option('--no-sound', dest='no_sound', action='store_true',
         help='disable the sounds module', default=False)
     parser.add_option('--no-notif', dest='no_notif', action='store_true',
         help='disable the notifications module', default=False)
     
     (options, args) = parser.parse_args()
     
     self.config = None
     self.global_cfg = ConfigApp()
     self.protocol_cfg = {}
     self.profile = None
     self.testmode = options.test
     self.interface = options.interface
     self.no_sound = options.no_sound
     self.no_notif = options.no_notif
     self.httpserv = None
     self.api = None
     self.version = self.global_cfg.read('App', 'version')
     
     for p in PROTOCOLS:
         self.protocol_cfg[p] = ConfigProtocol(p)
     
     if options.debug or options.clean: 
         logging.basicConfig(level=logging.DEBUG)
     else:
         logging.basicConfig(level=logging.INFO)
     self.log = logging.getLogger('Controller')
     
     if options.clean:
         self.__clean()
         sys.exit(0)
         
     if options.version:
         print "Turpial v%s" % self.version
         print "Python v%X" % sys.hexversion
         sys.exit(0)
         
     if options.save:
         try:
             self.__save_credentials()
         except KeyboardInterrupt:
             self.log.debug('Interceptado Keyboard Interrupt')
         sys.exit(0)
         
     self.interface = options.interface
     if options.interface == 'gtk+' and ('gtk+' in INTERFACES):
         self.ui = _GTK(self, extend=True)
     elif options.interface == 'gtk' and ('gtk' in INTERFACES):
         self.ui = _GTK(self)
     elif options.interface == 'cmd' and ('cmd' in INTERFACES):
         self.ui = _CMD(self, args)
     else:
         print 'No existe una interfaz válida. Las interfaces válidas son: %s' % INTERFACES
         print 'Saliendo...'
         sys.exit(-1)
     
     self.httpserv = HTTPServices()
     self.api = TurpialAPI()
     
     self.log.debug('Iniciando Turpial v%s' % self.version)
     if self.interface  != 'cmd':
         self.httpserv.start()
     self.api.start()
     self.api.change_api_url(self.global_cfg.read('Proxy', 'url'))
     
     if self.testmode:
         self.log.debug('Modo Pruebas Activado')
         
     self.ui.show_login()
     try:
         self.ui.main_loop()
     except KeyboardInterrupt:
         self.log.debug('Interceptado Keyboard Interrupt')
         self.ui.main_quit()