Example #1
0
 def getApplications(self, show_hidden=False):
     apps = {}
     hiddens = []
     appdatalist = self.getBuiltinApplications()
     appdatalist.extend(self.research(leginondata.ApplicationData()))
     for appdata in appdatalist:
         appname = appdata['name']
         if appname not in apps:
             app = application.Application(self, name=appname)
             if show_hidden:
                 apps[appname] = app
             else:
                 if appname not in hiddens:
                     if appdata['hide']:
                         hiddens.append(appname)
                     else:
                         apps[appname] = app
     if not show_hidden:
         history, map = self.getApplicationHistory()
         for appname in history:
             if appname not in apps:
                 app = application.Application(self, name=appname)
                 apps[appname] = app
     appnames = apps.keys()
     appnames.sort()
     orderedapps = ordereddict.OrderedDict()
     for appname in appnames:
         orderedapps[appname] = apps[appname]
     return orderedapps
Example #2
0
    def initialize_thread(self, worker_id, args, workers, slave, job_id):
        # thread to do the work
        #print('job_id', job_id)
        # map node_number to list
        # self._logger.info('Worker %s initializing' % self.worker_id)
        
        self._msgin = defaultdict(list)
        self._msgout = defaultdict(list)
        self._graph = defaultdict(list)
        self._nodeValue = {}
        self.last_round_msgin = {}
        self.partition = {}

        self._slave = slave
        self.worker_id = worker_id
        self.job_id = job_id
        self.set_peers(workers)

        self._logger.info('Worker %s initializing' % self.worker_id)
        self._slave.get(SAVA_APP_PY, SAVA_APP_PY)
        import application

        reload(application)
        self.application = application.Application(args)
        self._max_iter = self.application.max_iter
        self._iter_cnt = 0
        initial_values = self.application.init_values();
        self.load_graph(initial_values[0], initial_values[1])

        self._logger.info('worker init done')
Example #3
0
 def test_no_vid_source_int(self):
     result = False
     try:
         app = application.Application(5)
     except app_error.AppError:
         result = True
     self.assertTrue(result, msg='Does not recognise bad int vid source')
Example #4
0
    def create_tree_frame(self, frame_style, icon, main_geometry):
        self.tree_frame = wx.Frame(self,
                                   -1,
                                   _('wxGlade: Tree'),
                                   style=frame_style,
                                   name='TreeFrame')
        self.tree_frame.SetIcon(icon)

        app = application.Application()
        common.app_tree = WidgetTree(self.tree_frame, app)
        self.tree_frame.SetSize((400, 700))

        def on_tree_frame_close(event):
            #menu_bar.Check(TREE_ID, False)
            self.tree_frame.Hide()

        self.tree_frame.Bind(wx.EVT_CLOSE, on_tree_frame_close)

        # set geometry
        tree_geometry = None
        if config.preferences.remember_geometry:
            tree_geometry = config.preferences.get_geometry('tree')
            if isinstance(tree_geometry, tuple):
                tree_geometry = wx.Rect(*tree_geometry)
        if not tree_geometry:
            tree_geometry = wx.Rect()
            tree_geometry.Position = main_geometry.TopRight
            tree_geometry.Size = (400, 700)
            # sometimes especially on GTK GetSize seems to ignore window decorations (bug still exists on wx3)
            if wx.Platform != '__WXMSW__':
                tree_geometry.X += 10
        self._set_geometry(self.tree_frame, tree_geometry)
        self.tree_frame.Show()
Example #5
0
 def run(self):
     app = QtGui.QApplication(sys.argv)
     av = pyqt_application.Application()
     timer = QtCore.QTimer()  # set up your QTimer
     timer.timeout.connect(av.plot)  # connect it to your update function
     timer.start(2000)
     av.show()
     sys.exit(app.exec_())
Example #6
0
def main(style=utils.XBMC, auto=False):
    app = None
    try:
        app = application.Application()
        app.run(style, auto)
    except Exception, e:
        utils.log("******************* ERROR IN MAIN *******************")
        utils.log(e)
        raise
Example #7
0
def main(addonID, param=None):
    try:
        import application
        app = application.Application(addonID)
        app.run(param)
        del app
    except Exception, e:
        utils.Log('******************* ERROR IN MAIN *******************')
        utils.Log(str(e))
        raise
Example #8
0
def main():

    # 解析命令行,从命令行中获取数据(必须是define提前定义好的才能获取到)
    options.parse_command_line()

    # tornado.web.Application的子类
    app = application.Application()

    http_server = tornado.httpserver.HTTPServer(app)
    http_server.listen(options.port)
    tornado.ioloop.IOLoop.current().start()
Example #9
0
 def run(self):
     self.logger.info(f"{application.Application._svc_name_} started")
     try:
         self.app = application.Application(self.logger, self.logFile)
         self.app.run()
     except:
         self.logger.error(
             f"{application.Application._svc_name_} failed:\n{traceback.format_exc()}",
         )
     self.logger.info(f"{application.Application._svc_name_} stopped")
     self.stoppedEvent.set()
    def test_init(self, mock_win, loader, ed):

        mock_win.WINDOW_STYLE_DEFAULT=-24

        app = application.Application((1, 3), 'test title', True)

        mock_win.assert_called_with(width=1, height=3, caption='test title', 
                visible=True, fullscreen=True, resizable=True, 
                style=-24, vsync=False, display=None,
                context=None, config=None)

        loader.assert_called_once_with(ed)

        app = application.Application()
        mock_win.assert_called_with(width=640, height=480, 
                caption='MegaMinerAI Bland Title Text',
                visible=True, fullscreen=False, resizable=True, 
                style=-24, vsync=False, display=None,
                context=None, config=None)

        loader.assert_called_with(app)
def start_tornado():
   #  Tornado server address and port number.
   tornado.options.define("address", default=get_bind_interface(),
                          help="network address/interface to bind to")
   tornado.options.define("port", default=8080, help="port number to bind to",
                          type=int)
   tornado.options.parse_command_line()

   zoptions = tornado.options.options
   zserver = tornado.httpserver.HTTPServer(app.Application() )
   zserver.listen(zoptions.port, zoptions.address)
   tornado.ioloop.IOLoop.instance().start()
    def test_run(self, pyglet, mock_win, gameloader):

        app = application.Application()

        app.run()

        self.assertFalse(app.loader.load.called)

        app.run(['1.glog', '6.glog', '3.glog']) 

        self.assertEqual(pyglet.clock.schedule.call_count, 2)
        self.assertEqual(pyglet.app.run.call_count, 2)
Example #13
0
    def launchPreviousApp(self):
        names, launchers = self.getApplicationHistory()
        prevname = names[0]
        prevlaunchers = launchers[prevname]

        hostnames = [p[1] for p in prevlaunchers]
        self.waitForLaunchersReady(hostnames)

        app = application.Application(self, prevname)
        app.load()
        for alias, hostname in prevlaunchers:
            app.setLauncherAlias(alias, hostname)
        self.runApplication(app)
Example #14
0
def main(app_name):
    app_path = join(curdir, app_name)
    xml_path = join(app_path, 'view.xml')

    views = parser.parse_xml(xml_path)
    try:
        globals.app = __import__(app_name + '.extensions', fromlist=[app_name])
    except ImportError as e:
        stderr.write(e.message + '\n')
        return

    main_window = application.Application(views[0], views[1])
    globals.views = main_window.extensions
    main_window.start(views[2])
Example #15
0
 def post(self, *args, **kwargs):
     db = application.Application().db
     context={}
     email=self.get_argument('email',default=None)
     input_password=self.get_argument('password',default=None)
     sql="select password from user where id = (select id from user_info where email = %s)"
     password=db.query(sql,email)
     if input_password.encode('utf-8') == base64.b64decode(password[0]['password'].encode('utf-8')):
         self.set_secure_cookie('user',email)
         #context['authenticated']='200'
         self.redirect('/')
     else:
         context['authenticated']='500'
         self.write(context)
    def test_request_update_on_draw(self, mock_win):
        app = application.Application()
        self.assertEqual(len(app.updates), 2)

        app.updates = []

        app.request_update_on_draw('b')
        self.assertListEqual(app.updates, [(50, 'b')])
 
        app.request_update_on_draw('c', -23)
        self.assertListEqual(app.updates, [(-23, 'c'), (50, 'b')])
        app.request_update_on_draw('d', 0)
        app.request_update_on_draw('e', 100)
        self.assertListEqual(app.updates, 
                [(-23, 'c'), (0, 'd'), (50, 'b'), (100, 'e')])
Example #17
0
 def post(self, *args, **kwargs):
     context={'status':'500'}
     file_metas=self.request.files.get('file',None)
     try:
         db = application.Application().db
         uploadfile(file_metas)
         sql='insert into uploadfiles (user_id,file_name) select id,%s from user_info where email = %s'
         for file_meta in file_metas:
             file_name=file_meta['filename']
             file_name=check_file_name(file_name)
             db.insert(sql,file_name,self.user)
         context['status']='200'
     except Exception as e:
         print(e)
     self.write(context)
     self.finish()
Example #18
0
def main():
    pygame.init()

    screen = pygame.display.set_mode((935, 400))
    icon = pygame.image.load('./images/kticon.png')
    pygame.display.set_icon(icon)
    pygame.display.set_caption('Keyboard Tester')

    import application

    app = application.Application()

    while True:
        app.listen()
        app.draw(screen)
        app.update(screen)
Example #19
0
    def SvcDoRun(self):
        logDir = WindowsService.__getLogDir()
        logFile = os.path.join(logDir, f"{self._svc_name_}.log")
        try:
            os.makedirs(logDir)
        except OSError as err:
            if err.errno != errno.EEXIST:
                raise

        def namer(name):
            return name + ".zip"

        def rotator(source, dest):
            with zipfile.ZipFile(dest, 'w') as zf:
                zf.write(source, os.path.basename(source))
            os.remove(os.path.basename(source))

        lh = logging.handlers.RotatingFileHandler(
            filename=logFile,
            encoding="utf-8",
            maxBytes=self._log_max_bytes_,
            backupCount=self._log_backup_count_)
        lh.rotator = rotator
        lh.namer = namer
        lh.setFormatter(
            logging.Formatter('%(asctime)s %(levelno)s %(message)s'))

        log = logging.getLogger(self._svc_name_)
        log.propagate = False
        log.setLevel(logging.INFO)
        log.addHandler(lh)

        log.info(f"{self._svc_name_} started")
        servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
                              servicemanager.PYS_SERVICE_STARTED,
                              (self._svc_name_, ''))

        try:
            self.__app = application.Application(log, logFile)
            self.__app.run()
        except:
            log.error(f"{self._svc_name_} failed:\n{traceback.format_exc()}", )

        log.info(f"{self._svc_name_} stopped")
        servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
                              servicemanager.PYS_SERVICE_STOPPED,
                              (self._svc_name_, ''))
Example #20
0
    def __init__(self, update='all'):
        tables = {
            'credit':
            credit.Credit() if update == 'all' or
            ('credit' in update) else credit.Credit.from_cache(),
            'bureau':
            bureau.Bureau() if update == 'all' or
            ('bureau' in update) else bureau.Bureau.from_cache(),
            'prev':
            prev.Prev() if update == 'all' or
            ('prev' in update) else prev.Prev.from_cache(),
            'install':
            install.Install() if update == 'all' or
            ('install' in update) else install.Install.from_cache(),
            'cash':
            pos_cash.PosCash() if update == 'all' or
            ('cash' in update) else pos_cash.PosCash.from_cache(),
            'app':
            application.Application() if update == 'all' or
            ('app' in update) else application.Application.from_cache()
        }

        print('transform...')
        for k, v in tables.items():
            print(k)
            v.fill()
            v.transform()

        df = tables['app'].df

        for k, v in tables.items():
            if k == 'app':
                continue

            df = v.aggregate(df)
            print('{} merged. shape: {}'.format(k, df.shape))

        df = tables['app'].transform_with_others(df, tables['prev'].df,
                                                 tables['cash'].df,
                                                 tables['credit'].df)
        print('transform finished. {}'.format(df.shape))

        self.tables = tables
        self.df = df
        self._load_exotic()
        self._delete_columns()
Example #21
0
    def create_application_from_json(self, json_path):
        print("creating application from", json_path)

        self.open_json(json_path)

        self.file_path = json_path.rpartition('/')[0] + '/'

        self.app = application.Application()

        # self.app.window = self.load_window()

        self.create_scenegraph_nodes()
        self.create_field_containers()

        self.app.basic_setup()
        self.app.apply_field_connections()

        return self.app
Example #22
0
 def post(self, *args, **kwargs):
     context={}
     email=self.get_argument('email',default=None)
     password=self.get_argument('password')
     password_again=self.get_argument('password_again')
     if len(password)<8:
         context['password_length_error']='密码至少8个字符'
     if password_again!=password:
         context['password_input error']='两次密码输入不一致'
     else:
         db = application.Application().db
         password=base64.b64decode(password.encode('utf-8'))
         sql='insert into user (password) values (%s)'
         db.insert(sql,password)
         account=random.randint(10000000,99999999)
         sql=' insert into user_info (account,email) values (%s,%s)'
         db.insert(sql,account,email)
         context['status']='200'
     self.write(context)
    def test_update(self, mock_win):
        app = application.Application()

        func1, func2, func3 = MagicMock(), MagicMock(), MagicMock()

        app._update(4)
        self.assertEqual(app.window.clear.call_count, 1)

        # Make sure the functions start in an uncalled state
        for i in [func1, func2, func3]:
            self.assertFalse(i.called)

        # add them to the update request list
        app.updates = [(0, func1), (24, func2), (85, func3)]

        app._update(5)

        # Make sure all the functions have been called exactly once
        for i in [func1, func2, func3]:
            self.assertEqual(i.call_count, 1)
Example #24
0
def command_line_code_generation(filename, language, out_path=None):
    """Starts a code generator without starting the GUI.

    filename: Name of wxg file to generate code from
    language: Code generator language
    out_path: output file / output directory"""
    import application, tree
    # Instead of instantiating a main.wxGlade() object, that is
    # derived from wx.App, we must do the equivalent work.  The
    # following lines are taken from main.wxGlade().OnInit() and
    # main.wxGladeFrame.__init__()
    common.init_preferences()
    common.root = app = application.Application()
    # The following lines contain code from tree.WidgetTree.__init__()
    if config.use_gui:
        common.app_tree = tree.WidgetTree(root_node, app)

    # Now we can load the file
    if filename is not None:
        b = _guiless_open_app(filename)
        if not b:
            sys.exit(1)
    try:
        if language not in common.code_writers:
            raise ValueError('Code writer for "%s" is not available.' %
                             language)
        common.root.properties["language"].set(language)
        common.root.generate_code(out_path=out_path)
    except errors.WxgBaseException as inst:
        if config.debugging: raise
        logging.error(inst)
        sys.exit(inst)
    except Exception:
        if config.debugging: raise
        logging.error(
            _("An exception occurred while generating the code for the application.\n"
              "If you think this is a wxGlade bug, please report it."))
        logging.exception(_('Internal Error'))
        sys.exit(1)
    sys.exit(0)
Example #25
0
    def Run(self):
        global __app

        _uid, _gid = self.__GetUserAndGroup()

        if _uid is None:
            _uid = os.getuid()
        if _gid is None:
            _gid = os.getgid()

        self.__MakeLockDir(_uid, _gid)
        self.__MakeLogDir(_uid, _gid)

        log = logging.getLogger(self._svc_name_)
        log.propagate = False
        lh = None
        if os.path.exists(self._logrotate_file_):
            lh = logging.handlers.WatchedFileHandler(filename=self._log_file_,
                                                     encoding="utf-8")
        else:
            import gzip

            def namer(name):
                return name + ".gz"

            def rotator(source, dest):
                with open(source, 'rb') as fsrc:
                    with gzip.open(dest, 'wb') as fdst:
                        shutil.copyfileobj(fsrc, fdst)

            lh = logging.handlers.RotatingFileHandler(
                filename=self._log_file_,
                encoding="utf-8",
                maxBytes=self._log_max_bytes_,
                backupCount=self._log_backup_count_)
            lh.rotator = rotator
            lh.namer = namer

        lh.setFormatter(
            logging.Formatter('%(asctime)s %(levelno)s %(message)s'))
        log.setLevel(logging.INFO)
        log.addHandler(lh)

        context = daemon.DaemonContext(
            files_preserve=[lh.stream],
            uid=_uid,
            gid=_gid,
            umask=0o002,
            pidfile=lockfile.pidlockfile.PIDLockFile(self._lock_file_))

        context.signal_map = {signal.SIGTERM: NixService.__StopHandler}

        with context:
            print("Started")
            log.info(f"{self._svc_name_} started")
            try:
                __app = application.Application(log, self._log_file_)
                __app.run()
            except:
                print(traceback.format_exc())
                log.error(
                    f"{self._svc_name_} failed:\n{traceback.format_exc()}")
            log.info(f"{self._svc_name_} stopped")
            print("Stopped")
Example #26
0
if __name__ == "__main__":
    # Import our application
    import application

    # Create an application object
    App = application.Application()

    # Run our apps mainloop
    App.mainloop()
Example #27
0
def main():
    app = application.Application()  # создали объект класса- переход в Init
    app.execute()
Example #28
0
import application

game = application.Application()

game.start()
game.run()
game.stop()
Example #29
0
def app():
    return application.Application('firefox')
Example #30
0
def main():
    application.Application().run()