def main(args=None): """The main routine.""" if args is None: args = sys.argv[1:] app = App() app.run()
def createApps(self): # create app launchers self.apps = {} for app_detail in AppProvider.getAppList(True): self.apps[app_detail[0]] = App(self, app_detail) self.apps[app_detail[0]].window.hide()
def setUp(self): root = tk.Tk() self.app = App(master=root) auto_clicker_1 = AutoClickers('Factory', 5.0, 15.0, 0) auto_clicker_2 = AutoClickers('Farm', 15.0, 45.0, 3) self.purchase_button_1 = PurchaseButton(self.app, auto_clicker_1) self.purchase_button_2 = PurchaseButton(self.app, auto_clicker_2)
def OnInit(self): self.frame = Frame(None,title ="demo") self.SetTopWindow(self.frame) app = App.App(self,wx) app.autoload() self.frame.Show() return True
def test_view__all_classes(self): a = App(Login(DjangoInterface()), UserEdits(), CourseEdit()) result = a.command("LoggedInUser") # Error cases self.assertEqual("Not enrolled in any classes", result) # Success self.assertEqual("List of classes: ", result)
def main(): # Read in the data cards = pd.read_csv('data/cards.csv') heroes = pd.read_csv('data/heroes.csv') # Initialize a database manager and establish connection to the database db = HSDB() db.connect('data/hs.sqlite') # Drop all tables db.drop_table("Cards") db.drop_table("Classes") db.drop_table("Heroes") db.drop_table("minions") db.drop_table("spells") db.drop_table("weapons") db.drop_table("class_cards") db.drop_table("keywords") db.drop_table("keyword_cards") # this fn will generate and populate Heroes, Classes, Cards, and other related tables # for use from the cards/classes/heroes csv files. db.create_tables_from_data(cards, heroes) # Start the application app = App(db) app.run()
def main(): appContainer = AppContainer(App()) try: appContainer.start() except (BrokenPipeError, ConnectionResetError): pass finally: appContainer.cleanup()
def test_ViewDatabase(self): a = App(Login(DjangoInterface()), UserEdits(), CourseEdit()) result = a.command("LoggedInUser") # Error cases self.assertEqual("Illegal permissions to do this activity", result) self.assertEqual("Error while connecting to the database", result) # Success self.assertEqual("Data gathered", result)
def send_email(self): a = App(Login(DjangoInterface()), UserEdits(), CourseEdit()) result = a.command("From To Subject Body User UpdatedUser") # Error cases self.assertEqual("From user does not exist", result) self.assertEqual("To user does not exist", result) self.assertEqual("Illegal email subject", result) self.assertEqual("Illegal email body", result) # Success self.assertEqual("Email successfully sent", result)
def test_send__TA_email(self): a = App(Login(DjangoInterface()), UserEdits(), CourseEdit()) result = a.command("From To Subject Body TA UpdatedUser") # Error cases self.assertEqual("Illegal permissions to do this activity", result) self.assertEqual("TA(s) do not exist", result) self.assertEqual("Illegal email subject", result) self.assertEqual("Illegal email body", result) # Success self.assertEqual("Email sent to TA(s) successfully", result)
def test_update_time(): app = App(fake_server) app.logic.spawn_system.create_player(0) for i in range(15): app.logic.spawn_system.create_enemy() start = time.time() for i in range(100): app.update() delta = time.time() - start assert delta / 100 < 0.005
def main(): # Command line arguments if len(sys.argv) != 3 or (sys.argv[2] != "gui" and sys.argv[2] != "console"): print("usage: " + sys.argv[0] + " <input sudoku filename> <gui/console>") return sudoku_file = sys.argv[1] gui_active = (sys.argv[2] == "gui") app = App(gui_active, sudoku_file) app.run()
def test_animation_system(): app = App(fake_server) app.logic.spawn_system.create_player(0) anim_system = app.logic.animation_system anim_system.add_entity(0) start = time.time() for i in range(int(1000)): anim_system.get_animation_state(0) delta = time.time() - start assert delta < 0.005
def test_delete_course(self): a = App(Login(DjangoInterface()), UserEdits(), CourseEdit()) a.command("login brokenUsername brokenPassword") result1 = a.command("delete_course testCurse") a.command("logout") a.command("login testUsername testPassword") result2 = a.command("delete_course badID") result3 = a.command("delete_course testCourse") # Error cases self.assertEqual("Illegal permissions to do this action", result1) self.assertEqual("Course unsuccessfully deleted", result2) # Success self.assertEqual("Course successfully deleted", result3)
def test_change_contact_info(self): a = App(Login(DjangoInterface()), UserEdits(), CourseEdit()) a.command("login testUsername testPassword") result1 = a.command("change_contact testUsername name SAUCE") result2 = a.command("change_contact testUsername username *") result3 = a.command("change_contact testUsername address newaddress") # Error cases self.assertEqual("Illegal changed field", result1) # Tried to change an illegal field self.assertEqual( "Invalid parameter for this command", result2) # Updated field was illegal, contact field valid. # Success self.assertEqual("Contact information changed", result3)
def test_update_time(): src.utility.constants.ROOMS = 10 app = App(fake_server) app.logic.spawn_system.create_player(0) for i in range(400): app.logic.spawn_system.create_enemy() start = time.time() for i in range(100): try: app.update() except SystemExit: pass delta = time.time() - start assert delta / 100 < 0.1
def retriveApps(self): apps = [] data = self.getData() if "apps" in data: appsData = data["apps"] for appKey in appsData: appData = appsData[appKey] id = appData["id"] name = appData["name"] isActive = appData["isActive"] index = appData["index"] app = App(id, name, isActive) app.setIndex(index) apps.append(app) return apps
def main(): dir = os.path.dirname(__file__) config = loadConfig(dir) initLogging(dir, config) #Run app on a new thread app = App(config) app.run() #Reconnects in case of error recon = Reconnect(app, config) recon.start() #Control server server = ControlServer(app, config) server.start()
def test_login_to_database(self): a = App(Login(DjangoInterface()), UserEdits(), CourseEdit()) # assume username is in the directory/database result1 = a.command("login BadUser testPassword") result2 = a.command("login testUsername BadPass") result3 = a.command("login testUsername testPassword") # Error cases self.assertEqual("User does not exist", result1) # Username will trip this failure first. self.assertEqual( "Incorrect username/password", result2) # Result will contain an existing user with a bad pass # Success self.assertEqual( "User logged in", result3) # Username and password exist in the database.
def retriveAppsDict(self): appsDict = {} data = self.getData() if "apps" in data: appsData = data["apps"] # Converts json data to python object for appKey in appsData: appData = appsData[appKey] id = appData["id"] name = appData["name"] isActive = appData["isActive"] index = appData["index"] app = App(id, name, isActive) app.setIndex(index) appsDict[id] = app return appsDict
def test_assign_TA(self): a = App(Login(DjangoInterface()), UserEdits(), CourseEdit()) a.command("login brokenUsername brokenPassword") result1 = a.command("add_TA_to_course testCourse TAUsername") a.command("logout") a.command("login testUsername testPassword") result2 = a.command("add_TA_to_course testCourse badTA") result3 = a.command("add_TA_to_course badCourse TAUsername") result4 = a.command("add_TA_to_course testcourse 101 badLab") result5 = a.command("add_TA_to_course testCourse TAUsername") # Error cases self.assertEqual("Illegal permissions to do this action", result1) self.assertEqual("TA does not exist", result2) self.assertEqual("Failed to add TA to course.", result3) # self.assertEqual("Lab section Does not exist", result4) # Success self.assertEqual("TA successfully added to course", result5) a.command("logout")
def test_add_user(self): a = App(Login(DjangoInterface()), UserEdits(), CourseEdit()) a.command("login brokenUsername brokenPassword") result1 = a.command( "add_user newUsername newPassword 0000 address phonenum email") a.command("logout") a.command("login testUsername testPassword") result2 = a.command( "add_user ***** newPassword 0000 address phonenum email") result3 = a.command("add_user username * 0000 address phonenum email") result4 = a.command( "add_user newUsername newPassword 0000 address phonenum email") # Error cases self.assertEqual("Illegal permissions to do this action", result1) self.assertEqual("Failed to add user. Improper parameters", result2) self.assertEqual("Failed to add user. Improper parameters", result3) # Success self.assertEqual("User successfully added", result4) a.command("logout")
def loadAndExtractApps(self, appsDict, treeRoot=None): # self.log.d(self.TAG, "loadAndExtractApps") if self.tree is None: # self.log.d(self.TAG, "loadAndExtractApps self.tree is None") self.tree = GMenu.Tree.new(self.APPS_ID, GMenu.TreeFlags.SORT_DISPLAY_NAME) self.tree.connect("changed", self.treeOnChange) try: self.tree.load_sync() except Exception as e: self.log.e(self.TAG, Error.ERROR_8011, e) if treeRoot is None: root = self.tree.get_root_directory() else: root = treeRoot it = None if root is not None: it = root.iter() if it is not None: while True: treeItemType = it.next() if treeItemType is GMenu.TreeItemType.INVALID: break if treeItemType is GMenu.TreeItemType.DIRECTORY: dir = it.get_directory() # self.log.d(self.TAG, "loadAppList dir %s : " % dir) self.loadAndExtractApps(appsDict, dir) elif treeItemType is GMenu.TreeItemType.ENTRY: info = it.get_entry().get_app_info() # self.log.d(self.TAG, info.get_display_name()) id = info.get_id() if id not in appsDict: appsDict[id] = info if id in self.activeAppsDict: app = self.activeAppsDict[id] app.setId(id) app.setInfo(info) self.activeApps.insert(app.getIndex(), app) else: app = App(id, info.get_display_name(), False) app.setInfo(info) self.inactiveApps.append(app)
def test_create_course(self): a = App(Login(DjangoInterface()), UserEdits(), CourseEdit()) a.command("login brokenUsername brokenPassword") result1 = a.command( "create_course testUsername testCourse 10:00 10:50") a.command("logout") a.command("login testUsername testPassword") result2 = a.command( "create_course testUsername testCourse 10:00 10:50") result3 = a.command("create_course testUsername badTime 10:50") result4 = a.command("create_course testUsername 10:00 badTime") result5 = a.command( "create_course testUsername testcourse 10:00 10:50") result6 = a.command( "create_course testUsername testCourse 10:00 10:50") # Error cases self.assertEqual("Illegal permissions to do this action", result1) # self.assertEqual("Illegal start time entered", result3) # self.assertEqual("Illegal end time entered", result4) # Success self.assertEqual("Course successfully added", result6) a.command("logout")
from App import App if __name__ == '__main__': theApp = App() theApp.on_execute()
App.Gradient.running = False App.Gradient.thread.join() if (App.Rainbow.running): App.Rainbow.running = False App.Rainbow.thread.join() if (App.Weather.running): App.Weather.running = False App.Weather.thread.join() App.exit() sys.exit(0) # Catch SIGINT to clean up first signal.signal(signal.SIGINT, exit_handler) App = App() # Notify connect App.Flash.apply(2, 0.6, "#00ff00", "#ffffff") App.Gradient.apply(2, "#00ff00", "#ffffff") # Main menu command = "" wrong_command = False while True: # Clear terminal screen os.system('cls' if os.name == 'nt' else 'clear') # Print menu print(TEXT_WELCOME)
def __init__(self): self.__dockerShell = DockerShell() app = App(self.__dockerShell).run()
import bluetooth import time from App import App # from notice import notice # import threading # import lightblue # need turn on blurtooth before call # MAC HC05 : 98:D3:31:F9:40:8A addr = '98:D3:31:F9:40:8A' app = App(addr) while True: app.send_to_show() time.sleep(0.5)
# https://www.pythontutorial.net/tkinter/tkinter-thread-progressbar/ from PictureDownload import PictureDownload from App import App if __name__ == '__main__': # url = 'https://source.unsplash.com/random/640x480' # download = PictureDownload(url) # download.start() # download.join() # print("finished") app = App(640, 480) app.mainloop()
import sys from App import App from PyQt5.QtWidgets import QApplication if __name__ == '__main__': app = QApplication(sys.argv) ex = App() sys.exit(app.exec_())