def test_app_types(self): ff = Application("firefox.desktop", pid=1, tstart=0, tend=2) cf = Application("catfish.desktop", pid=2, tstart=21, tend=32) th = Application("thunar.desktop", pid=3, tstart=5, tend=8) gd = Application("gnome-disks.desktop", pid=4, tstart=2, tend=4) self.assertTrue(ff.isUserlandApp()) self.assertTrue(cf.isDesktopApp()) self.assertTrue(th.isDesktopApp()) self.assertTrue(gd.isDesktopApp())
def test_merge_equal_b(self): self.store.clear() a = Application("firefox.desktop", pid=18495, tstart=0, tend=2) b = Application("firefox.desktop", pid=245, tstart=21, tend=32) f = Application("firefox.desktop", pid=6023, tstart=2, tend=4) self.store.insert(a) self.store.insert(b) self.store.insert(f) self.assertEqual(len(self.store.lookupDesktopId(a.desktopid)), 3) self.assertEqual(len(self.store.lookupDesktopId(a.getDesktopId())), 3)
def __mul__(self, other): d = Application(multiplication, self) d = Application(d, other) d = d.fullreduce() dummy = lambnumber(0) dummy.head = d.head dummy.body = d.body dummy.number = self.number * other.number return dummy
def test_merge_equal(self): self.store.clear() a = Application("firefox.desktop", pid=21, tstart=0, tend=2) b = Application("firefox.desktop", pid=21, tstart=21, tend=32) d = Application("ristretto.desktop", pid=21, tstart=5, tend=8) f = Application("firefox.desktop", pid=21, tstart=2, tend=4) self.store.insert(a) self.store.insert(b) self.store.insert(d) self.store.insert(f) self.assertEqual(len(self.store.lookupPid(21)), 3)
def main(): root = Tk() root.title("Pokemon Battle") root.geometry("670x500") app = Application(root) root.mainloop()
def initialSetup(): global parameter # ValueHandler init global valueHandler valueHandler = ValueHandler(parameter) # Sets the correct default channel values for x in xrange(0, parameter['nrChannels']): parameter['channelData'].append(parameter['defaultChannelData'][x]) # Reset the starting values parameter['channelOutput'].append(valueHandler.getOutput(parameter['channelData'][x], x)) # Calculating the correct output # ComLink init global comLink comLink = Communication(parameter) # Controller init global controller controller = LeapMotion(parameter['channelData'], parameter['nrChannels'], parameter['controllerTrim']) # Main app setup global appGUI appGUI = Tk() appGUI.geometry('800x468+100+100') appGUI.resizable(0,0) # Main app init global application application = Application(appGUI, controller, comLink, valueHandler, parameter)
def listMissingActors(self): """Check for missing apps. Go through the SQLite database and print the list of .desktop files that are missing on the system used for analysis. Exits if some apps are missing. """ self.cur = self.con.cursor() self.cur.execute('SELECT * from actor') hasErrors = False data = self.cur.fetchall() invalidApps = set() for listing in data: try: app = Application(desktopid=listing[1]) except(ValueError) as e: print("MISSING: %s" % listing[1], file=sys.stderr) invalidApps.add(listing[1]) hasErrors = True if invalidApps and hasErrors: print("Invalid apps:", file=sys.stderr) for a in sorted(invalidApps): print("\t%s" % a, file=sys.stderr) sys.exit(-1)
def Main(args): driverSettings = DriverSettingsForm( "Texture paint example", "This example shows how to use TexturePainter and render-to-texture (RTT) technique.\n\n" + "Use mouse to draw on the 2D image (texture) and see changes on the mesh and on RTT target." ) if not driverSettings.ShowDialog(): return device = IrrlichtDevice.CreateDevice( driverSettings.DriverType, driverSettings.VideoMode.Resolution, driverSettings.VideoMode.Depth, driverSettings.Fullscreen) if device == None: Console.WriteLine( "\nDevice creation failed!\n<Press any key to exit>") Console.ReadKey() return app = Application(device) lastFPS = -1 while device.Run(): device.VideoDriver.BeginScene() app.Render() device.VideoDriver.EndScene() fps = VideoDriver.FPS if fps != lastFPS: device.SetWindowCaption( String.Format( "Texture painting example - Irrlicht Lime [{0}] {1} fps", device.VideoDriver.Name, fps)) lastFPS = fps device.Drop()
def main(): root = Tk() root.title("Minesweeper") app = Application(root) root.mainloop()
def main(): setLog() pid = daemon() if pid: return pid app = Application() app.run_forever()
def wrapper(obj, *args, **kwargs): signalName = name if type(name) is str else fn.__name__ ctx = obj.context if hasattr( obj, 'context') else Application().pluginContext retval = fn(obj, *args, **kwargs) SignalManager(ctx).sendSignal(signalName, *args, **kwargs) return retval
def test_insert_sorted(self): self.store.clear() app = Application("firefox.desktop", pid=21, tstart=0, tend=10) first = Event(app, 1, syscallStr="test") second = Event(app, 2, syscallStr="test") third = Event(app, 3, syscallStr="test") forth = Event(app, 4, syscallStr="test") fifth = Event(app, 5, syscallStr="test") sixth = Event(app, 6, syscallStr="test") seventh = Event(app, 7, syscallStr="test") eight = Event(app, 8, syscallStr="test") self.store.insert(eight) self.store.insert(first) self.store.insert(sixth) self.store.insert(fifth) self.store.insert(third) self.store.insert(forth) self.store.insert(seventh) self.store.insert(second) alle = self.store.getAllEvents() sorte = [first, second, third, forth, fifth, sixth, seventh, eight] self.assertEqual(sorte, alle)
def main(): sg.change_look_and_feel('Dark Blue') # get the settings settings = Helper.getSettings() # set the theme sg.change_look_and_feel(settings['theme']) # if it doesn't exist, create the kwMap file if not os.path.isfile("kwMap.json"): print("Creating kwMap.json") with open("kwMap.json", "w") as fh: json.dump({}, fh) # generate base map if not os.path.isfile("subcatMap.json"): print("Creating subcatMap.json") Helper.generateBaseMap() # make an instance of the app class app = Application(settings['fileName'], settings['safeMode']) Helper.write2csv([Helper.timestamp()]) # writing timestamp Helper.write2csv([ "Date", "Backdate", "Description", "Transaction", "Balance", "Year", "Month", "Searchable Description", "Subcategory", "Category", "Bucket", "Class" ]) #writing titles app.loop() print(f"Finished at {Helper.timestamp()}") # Bookend
def setUpClass(cls): stdout, stderr = sys.stdout, sys.stderr if cls.catchOutput: sys.stdout = sys.stderr = StringIO() cls.currentDir = getcwd() import webware webwareDir = webware.__path__[0] chdir(webwareDir) try: app = Application(settings=cls.settings, development=True) cls.app = app cls.testApp = TestApp(app) except Exception as e: error = str(e) or 'Could not create application' else: error = None finally: if cls.catchOutput: output = sys.stdout.getvalue().rstrip() sys.stdout, sys.stderr = stdout, stderr else: output = '' if error: raise RuntimeError('Error setting up application:\n' + error + '\nOutput was:\n' + output) if cls.catchOutput and not (output.startswith('Webware for Python') and 'Running in development mode' in output and 'Loading context' in output): raise AssertionError('Application was not properly started.' ' Output was:\n' + output)
def test_merge_equal(self): app = Application("firefox.desktop", pid=21, tstart=1, tend=200000) self.appStore.insert(app) ss = "open64|/home/user/.kde/share/config/kdeglobals|fd " \ "10: with flag 524288, e0|" e1 = Event(actor=app, time=10, syscallStr=ss) self.eventStore.append(e1) cmd = "@firefox|2294|firefox -p /home/user/.kde/file" e2 = Event(actor=app, time=1, cmdlineStr=cmd) self.eventStore.append(e2) st = "open64|/home/user/.kde/file|fd " \ "10: with flag 524288, e0|" e3 = Event(actor=app, time=13, syscallStr=st) self.eventStore.append(e3) self.eventStore.simulateAllEvents() ef1 = EventFileFlags.no_flags ef1 |= EventFileFlags.programmatic ef1 |= EventFileFlags.read self.assertEqual(ef1, e1.getFileFlags()) ef3 = EventFileFlags.no_flags ef3 |= EventFileFlags.designation ef3 |= EventFileFlags.read file = self.fileFactory.getFile("/home/user/.kde/file", 20) accs = file.getAccesses() self.assertEqual(file.getAccessCount(), 1) self.assertEqual(next(accs).evflags, ef3)
def main(): # engine = Engine(app) FEL = FutureEventList() app = Application(FEL) print "Schedule for ALL the arrivals" poissons = np.random.poisson(app.poisson_mean, 10000) timestamp = 0 i = 0 # timestamps = np.cumsum(np.random.poisson(poisson_mean, size)) customers = [] while timestamp < 7200: customers.append(Customer(i, timestamp)) timestamp += poissons[i] i += 1 for j in range(i): FEL.schedule(customers[j].time['arrival'], customers[j], app.arrival) # FEL.schedule(Event(timestamp, Customer(), app.arrival_food)) # print "Schedule for First Order at", timestamp # engine.schedule(timestamp, # data = "testAppData", # callback = app.arrival_food, # pq = app.panda_attribute.queue_food) start_time = time() # engine.run_simulation() run_simulation(FEL) total_run_time = (time() - start_time) generate_statistics(customers)
def test_pol_load_app_conf(self): app = Application("ristretto.desktop", pid=21, tstart=0, tend=300) file = File("/home/user/Images/sample.jpg", 140, 0, "image/jpeg") file.addAccess(app, 140, EventFileFlags.create | EventFileFlags.read) res = self.mgr.getAppPolicy(app, libMod=LibraryManager.Default) self.assertEqual(len(res), 1) self.assertEqual(res[0], "image")
def setUp(self): self.app = Application() self.king_pik = Card(Suit.pik, self.app._ranks.K, 0, 0) self.dame_kier = Card(Suit.kier, self.app._ranks.D, 10, 10) self.doc = xml.dom.minidom.Document() self.xml_card = self.doc.createElement("Card") self.xml_card.setAttribute("rank", self.app._ranks.D.name) self.xml_card.setAttribute("suit", Suit.kier.name)
def setUp(self): self.eventStore = EventStore.get() self.appStore = ApplicationStore.get() self.fileFactory = FileFactory.get() self.fileStore = FileStore.get() self.userConf = UserConfigLoader.get("user.ini") self.ar1 = Application("ristretto.desktop", pid=21, tstart=1, tend=2000) self.ar2 = Application("ristretto.desktop", pid=22, tstart=2600, tend=2900) self.ag1 = Application("gimp.desktop", pid=23, tstart=1, tend=4000) self.ag2 = Application("gimp.desktop", pid=24, tstart=4500, tend=4590) self.appStore.insert(self.ar1) self.appStore.insert(self.ar2) self.appStore.insert(self.ag1) self.appStore.insert(self.ag2) # Insert a file that will bridge r1 and g1. s2 = "open64|/home/user/Images/Picture.jpg|fd 4: with flag 524288, e0|" e2 = Event(actor=self.ag1, time=10, syscallStr=s2) self.eventStore.append(e2) e2b = Event(actor=self.ar1, time=12, syscallStr=s2) self.eventStore.append(e2b) # Insert a file that will bridge r1 and r2. s3 = "open64|/home/user/Images/Photo.jpg|fd 10: with flag 524288, e0|" e3 = Event(actor=self.ar1, time=10, syscallStr=s3) self.eventStore.append(e3) e3b = Event(actor=self.ar2, time=2710, syscallStr=s3) self.eventStore.append(e3b) # Insert a file that will bridge g1 and g2. s4 = "open64|/home/user/Images/Art.xcf|fd 10: with flag 524288, e0|" e4 = Event(actor=self.ag1, time=10, syscallStr=s4) self.eventStore.append(e4) e4b = Event(actor=self.ag2, time=4540, syscallStr=s4) self.eventStore.append(e4b) # Simulate. self.eventStore.simulateAllEvents()
def test_get_inst_count(self): self.store.clear() a = Application("firefox.desktop", pid=18495, tstart=0, tend=2) b = Application("ristretto.desktop", pid=245, tstart=21, tend=32) c = Application("gimp.desktop", pid=5346, tstart=3, tend=239) d = Application("firefox.desktop", pid=1966, tstart=8, tend=99) e = Application("firefox.desktop", pid=44, tstart=1, tend=6) self.store.insert(a) self.store.insert(b) self.store.insert(c) self.store.insert(d) self.store.insert(e) count = self.store.getInstCountPerApp() self.assertEqual(len(count), 3) self.assertEqual(count["firefox"], 3) self.assertEqual(count["gimp"], 1) self.assertEqual(count["ristretto"], 1)
def main(): for arg in sys.argv[1:]: print(arg) app = QApplication(sys.argv) window = Application() window.setStyleSheet(open('stylesheet/default.qss').read()) window.show() # IMPORTANT!!!!! Windows are hidden by default. app.exec_()
def test_insert_identical_timestamps(self): self.store.clear() app = Application("firefox.desktop", pid=21, tstart=0, tend=3) lastapp = Application("ristretto.desktop", pid=22, tstart=3, tend=4) first = Event(app, 1, syscallStr="test") second = Event(app, 2, syscallStr="test") third = Event(app, 3, syscallStr="test") last = Event(lastapp, 3, syscallStr="test") self.store.insert(first) self.store.insert(third) self.store.insert(last) self.store.insert(second) alle = self.store.getAllEvents() sorte = [first, second, third, last] self.assertEqual(sorte, alle)
def setUp(self): self.app = Application() self.app.load_deck() self.field = Pile(0, 0) self.dame_kier = Card(Suit.kier, self.app._ranks.D, 20, 20) self.as_pik = Card(Suit.pik, self.app._ranks.AS, 20, 20) self.as_karo = Card(Suit.karo, self.app._ranks.AS, 20, 20) self.walet_trefl = Card(Suit.trefl, self.app._ranks.W, 20, 20) self.dame_trefl = Card(Suit.trefl, self.app._ranks.D, 20, 20)
def list_applications(self): url = "{0}/api/applications/list/".format(self._serverUrl) r = self.get(url) res = [] for values in r.json(): app = Application(self) app.load(values) res.append(app) return res
def main(): db = Database() db['screen_width'] = 800 db['screen_height'] = 450 db['locomotive_img'] = "locomotive.png" db['rails_img'] = "ClickerBg.png" db['font'] = "F77-Minecraft.ttf" app = Application("MyApp") app.create_window(db['screen_width'], db['screen_height'], "ClickerGame") return app.run()
def main_thread(): #thread gesture recognition t1 = threading.Thread(target=main_predict_on_thread) t1.start() #thread main run application app = QtWidgets.QApplication(sys.argv) player = Application() player.show() player.resize(640, 480) sys.exit(app.exec_())
def main(): root = Tk() root.title("Superhero Battle") root.geometry("520x400") root.configure(background="black") # Create the Frame and add components app = Application(root) # Run mainloop root.mainloop()
def setUp(self): self.eventStore = EventStore.get() self.appStore = ApplicationStore.get() self.fileFactory = FileFactory.get() self.userConf = UserConfigLoader.get("user.ini") self.engine = PolicyEngine() self.ar1 = Application("ristretto.desktop", pid=21, tstart=1, tend=2000) self.ar2 = Application("ristretto.desktop", pid=22, tstart=2600, tend=2900) self.ag1 = Application("gimp.desktop", pid=23, tstart=1, tend=4000) self.ag2 = Application("gimp.desktop", pid=24, tstart=4500, tend=4590) self.appStore.insert(self.ar1) self.appStore.insert(self.ar2) self.appStore.insert(self.ag1) self.appStore.insert(self.ag2)
def __init__(self): import gtk.glade import Paths import Signals xml = gtk.glade.XML(Paths.glade, 'preferences') Signals.autoconnect(self, xml) self.__dialog = xml.get_widget('preferences') import gconf from GConfDir import GConfDir self.__client = gconf.client_get_default() self.__dir = GConfDir(self.__client, Keys.root, gconf.CLIENT_PRELOAD_NONE) from AppFinder import AppFinder from AppModel import AppModel from Application import Application finder = AppFinder(self.__client) model = AppModel() for path in finder: Application(self.__client, model, path) from MasterNotifier import MasterNotifier from WindowIcon import WindowIcon self.__master = xml.get_widget('master') self.__apps_group = xml.get_widget('apps-group') self.__notifier = MasterNotifier(self.__client, self.__master_refresh) self.__icon = WindowIcon(self.__client, self.__dialog) view = xml.get_widget('applications') import gtk selection = view.get_selection() selection.set_mode(gtk.SELECTION_NONE) renderer = gtk.CellRendererText() column = gtk.TreeViewColumn('Application', renderer) column.set_cell_data_func(renderer, self.__name_data_func) column.set_sort_column_id(model.COLUMN_NAME) column.set_reorderable(True) column.set_resizable(True) view.append_column(column) renderer = gtk.CellRendererToggle() renderer.connect('toggled', self.on_application_toggled, model) column = gtk.TreeViewColumn('Enabled', renderer) column.set_cell_data_func(renderer, self.__enabled_data_func) column.set_sort_column_id(model.COLUMN_ENABLED) column.set_reorderable(True) view.append_column(column) view.set_model(model)
def __init__(self, section): super(Settings,self).__init__() self.section = section if Settings._config is None: self.configPath = Board.configDir() if not os.path.exists(self.configPath): os.makedirs(self.configPath) self.configFilename = 'Telldus.conf' self.__loadFile() Application().registerShutdown(self.__shutdown) if section not in Settings._config: Settings._config[section] = {}