def on_click(self): username = self.username.text() passw = self.pwd.text() mycu.execute('SELECT * FROM reg WHERE username = "******" AND password = "******"') res = mycu.fetchone() if (not res): QMessageBox.about(self, 'Login', 'Invalid Details!!') self.resetform() else: print('Logged in Successfully') self.Reply = QMessageBox.question(self, 'Login', "Logged in successfull", QMessageBox.Yes) if self.Reply == QMessageBox.Yes: print('Yes clicked.') from main import App self.m = App(username) self.m.show() self.close() mycu.execute('SELECT * FROM reg where username = "******"') res = mycu.fetchall() for x in res: global currentuser currentuser = x[0] global currentname currentname = x[3] self.m.l1.setText("<h2>Welcome %s</h2>" % currentuser)
class TestApp(unittest.TestCase): """Test full operation of the App class.""" def setUp(self): """Set up app redirecting output to a pipe.""" self.tempdir = tempfile.mkdtemp() self.log = os.path.join(self.tempdir(), "log.csv") with open(self.log, "w") as f: f.write(logfile) self.out = os.path.join(self.tempdir(), "out") self.app = App(self.log, 2, self.out) def tearDown(self): """Remove temporary files and directories.""" os.remove(self.log) os.remove(self.out) os.rmdir(self.tempdir) def run(self): """Run app and check results.""" self.app.run() self.assertEqual(len(self.tasks), 5) self.assertTrue( all(len(task.messages) == 0 for task in self.app.tasks.values())) self.assertListEqual(list(self.tasks.keys()), [ '101.81.133.jja', '107.23.85.jfd', '108.91.91.hbc', '106.120.173.jie', '107.178.195.aag' ]) self.assertEqual(self.tasks.output_queue.qsize(), 0) with open(self.out) as f: check = f.read() self.assertEqual(output, check)
def on_click(self): pwd1 = self.pwd1.text() add = self.address.text() pwd = self.pwd.text() user = self.a if (add == '' or pwd == '' or pwd1 == ''): QMessageBox.about(self, 'Update', 'Some fields are still incomplete!') else: if (pwd != pwd1): QMessageBox.about(self, "Password", "Password Doesn't Match") else: mycu.execute('SELECT password FROM reg WHERE username= "******"') res = mycu.fetchone() if (res == pwd): QMessageBox.about(self, 'Update', 'Enter the new Password!', QMessageBox.Yes) else: mycu.execute('UPDATE reg SET address = "' + add + '", password = "******" WHERE username= "******"') conn.commit() print('Updated Successfully') self.Reply = QMessageBox.question(self, "Update", " Update successfull", QMessageBox.Yes) if self.Reply == QMessageBox.Yes: from main import App self.m = App(self.a) self.m.show() self.close()
def check_multiline_calc(data, expected, capsys): output = DataOutputMethod() app = App(DataInputMethod(data), output) app.run() assert output.output == expected out, err = capsys.readouterr() assert err == ''
def setUp(self): """Set up app redirecting output to a pipe.""" self.tempdir = tempfile.mkdtemp() self.log = os.path.join(self.tempdir(), "log.csv") with open(self.log, "w") as f: f.write(logfile) self.out = os.path.join(self.tempdir(), "out") self.app = App(self.log, 2, self.out)
def test_persist(self, persist=None): """ test case to validate persist function :param persist: :return: """ print("------------validating persist function------------------") persist.return_value = 'test persist' t = App() assert t.persist() == 'test persist'
async def make_project_style(self): sys.path.append(self.source_path) from main import App app = App() css_tag_list = app.generate_css(current_tree=[])[-1] return generate_css_from_list(tag_list=css_tag_list)
def on_click3(self): #database connection conn = mysql.connector.connect(host="localhost", user="******", passwd="", database="mini") mycu = conn.cursor() mycu.execute("TRUNCATE "+self.a+"") QMessageBox.question(self, 'Food', 'Foods Booked') from main import App self.m=App(self.a) self.m.show() self.close()
def test_run(self, run=None): """ test case to validate run function :param run: :return: """ print("------------validating run function------------------") run.return_value = 'test run' t = App() assert t.run() == 'test run'
async def make_project(self): source = os.path.join(self.source_path, self.source_filename) if not os.path.exists(source): raise RuntimeError( handler_message( message="O caminho pra o projeto esta incorreto!", type="WARNING")) sys.path.append(self.source_path) from main import App app = App() return await self.join_project_source(source=app.generate_html())
def open_app(self): """打开应用程序""" self.quit() self.win_success.destroy() self.win_success.quit() App()
def __init__(self): self.game_finished = False # The App self.app = App(self) # the Printer self.printer = self.app.init_printer(10) # the Player self.player = Player(self.printer) # the Ship the_window = Window(self.printer) self.ship = Ship(the_window, self.printer) # Planets and initialisation self.citadel = Citadel("Citadel", self.ship, self.printer, self) self.fireplanet = Fireplanet("Paxak", self.ship, self.printer, self) self.planets = [self.citadel, self.fireplanet] # Initial Values of Important Fields self.current_planet = self.citadel self.current_location = self.citadel.current_location #self.game_finished = False # Final initialisation now that enough exists the_window.initialise(self) self.citadel.land() # the Parser and helpers self.parser = Parser() self.directions = [ "left", "right", "forwards", "forward", "ship", "spaceship", "out", "outside", "in", "inside", "back", "backwards", "citadel" ] noun_list = [] for object in self.current_location.objects: noun_list.extend(object.noun_names) self.parser.nouns = noun_list + self.directions # the StateHolder self.stateholder = StateHolder(self) self.start_game()
def start_server(self): if self._is_daemon_running(): return if not self.debug: # Disable daemon if debug is on daemon_context = self._get_daemon_context() daemon_context.open() App(logfile=self.logfile).run() # This is the main function of the daemon
def test_app(self, App=None): """ test case to validate app instantiation :param App: :return: """ print("------------validating instantiation of App------------------") App.return_value = 'app test' assert App() == 'app test'
def start_server(self): if self._is_daemon_running(): print "Daemon running, not starting" return if not self.debug: # Disable daemon if debug is on daemon_context = self._get_daemon_context() with daemon_context: App(logfile=self.logfile, loglevel=self.loglevel).run() # This is the main function of the daemon
def app_factory(config, app_name, blueprints=None): from main import App, PROJECT_PATH # you can use Empty directly if you wish app = App(app_name, root_path=PROJECT_PATH) config = config_str_to_obj(config) #print dir(config) app.configure(config) if blueprints: app.add_blueprint_list(blueprints) app.setup() return app
def test_cogo_labs_df(self, cogo_labs_df=None): """ test case to validate cogo_labs data frame property :param cogo_labs_df: :return: """ print("------------validating Cogo labs dataframe property------------------") cogo_labs_df.return_value = 'mock cogo labs dataframe' t = App() assert t.cogo_labs_df == 'mock cogo labs dataframe'
def test_live_works_df(self, live_works_df=None): """ test case to validate live works data frame property :param live_works_df: :return: """ print("------------validating live works dataframe property------------------") live_works_df.return_value = 'mock live works dataframe' t = App() assert t.live_works_df == 'mock live works dataframe'
def test_join_df(self, join_df=None): """ test case to validate join dataframe property :param join_df: :return: """ print("------------validating join dataframe property------------------") join_df.return_value = 'mock join dataframe' t = App() assert t.join_df == 'mock join dataframe'
def main(): """Handle CLI invocation""" # Parse our CLI arguments if argparse: parser = argparse.ArgumentParser(description="Console text editor with multi cursor support") parser.add_argument("filenames", metavar="filename", type=str, nargs="*", help="Files to load into Suplemon") parser.add_argument("--version", action="version", version=__version__) args = parser.parse_args() filenames = args.filenames else: # Python < 2.7 fallback filenames = sys.argv[1:] # Generate and start our application app = App(filenames=filenames) app.init() # Output log info if app.config["app"]["debug"]: app.logger.output()
def setUpModule(): global serverthread, cherryserver if os.path.isfile(CharryTestInfo.DB_FILE): os.remove(CharryTestInfo.DB_FILE) cherryserver = App() def begin(): cherryserver.start() serverthread = threading.Thread(target=begin) serverthread.start() time.sleep(1) print("Complete setup...............")
def ingresar(): user = usuario.get() clave = password.get() with open('usuarios.txt','r') as file: match = False for cadena in file.readlines(): nombre,rol,contrasenia,codigo1,codigo2,codigo3 = cadena.split(',') if nombre == user and clave == contrasenia: match = True break else: pass if match: login.destroy() App(usuario=nombre,rol=rol,codigo1=int(codigo1),codigo2=int(codigo2),codigo3=int(codigo3)) else: messagebox.showwarning('Advertencia','Usuario o contraseña incorrectos')
def getToc(): print('[INFO] API get TOC') if len(os.listdir(app.config['UPLOAD'])) == 10: os.system('rm -rf %s/*' % (app.config['UPLOAD'])) session_id = uuid.uuid1() message = {"success": None, "message": '', "detected": []} file_p = '' if request.method == 'GET': url = request.args['url'] file_p = os.path.join(app.config['UPLOAD'], str(session_id) + '.pdf') print(file_p) try: file_name = wget.download(url, out=file_p) except: message["success"] = False message["message"] = "Url error" resp = jsonify({"result": message}) return resp if not os.path.isfile(file_p): message["success"] = False message["message"] = "File not downloaded" resp = jsonify({"result": message}) return resp elif request.method == 'POST': if request.files['file'].filename == '': message["success"] = False message["message"] = "Not selected file" resp = jsonify({"result": message}) return resp else: file_p = os.path.join(app.config['UPLOAD'], str(session_id) + '.pdf') request.files['file'].save(file_p) data = App.detectToc(file_p, version=False) message["success"] = True message["message"] = "Successfully" message["detected"] = data return jsonify(message)
#!/usr/bin/env python from os import getenv import json import logging import random import math import numpy as np from tensorforce.agents import Agent from main import App app = App() app.init_screen() app.render() config = json.load(open(getenv('CONFIG', 'ppo.json'))) max_episodes = config.pop('max_episodes', None) max_timesteps = config.pop('max_timesteps', None) max_episode_timesteps = config.pop('max_episode_timesteps') network_spec = config.pop('network') agent = Agent.from_spec(spec=config, kwargs=dict( states=dict(type='float', shape=(len(app.get_state()), )), actions={ 'accel': dict(type='int', num_actions=3), 'turn': dict(type='int', num_actions=3),
from main import App App()
from main import App from src.args import args import multiprocessing import gunicorn.app.base from gunicorn.six import iteritems class StandaloneApplication(gunicorn.app.base.BaseApplication): def __init__(self, app, options=None): self.options = options or {} self.application = app super(StandaloneApplication, self).__init__() def load_config(self): config = dict([(key, value) for key, value in iteritems(self.options) if key in self.cfg.settings and value is not None]) for key, value in iteritems(config): self.cfg.set(key.lower(), value) def load(self): return self.application if __name__ == '__main__': options = { 'bind': '%s:%s' % (args.host, args.port), 'workers': args.workers, } StandaloneApplication(App().app, options).run()
def open_app(self): self.quit() self.win_success.destroy() self.win_success.quit() App()
class App(QMainWindow): def __init__(self,a): super().__init__() self.title = 'Book Food' self.left = 100 self.top = 100 self.width = 600 self.height = 500 self.a=a self.initUI() def initUI(self): self.setWindowTitle(self.title) self.setGeometry(self.left, self.top, self.width, self.height) #database connection conn = mysql.connector.connect(host="localhost", user="******", passwd="", database="mini") mycu = conn.cursor() self.lh = QLabel(self) self.lh.move(0, 0) self.lh.resize(600, 200) self.head = QPixmap('head.png') self.lh.setPixmap(self.head) self.lh.resize(self.head.width(), self.head.height()) self.l1=QLabel("Foods",self) self.l1.move(10,160) self.l2=QLabel("Hotels",self) self.l2.move(210,160) self.l3=QLabel("Rupees₹",self) self.l3.move(350,160) self.l1.setFont(QFont('SansSerif', 15)) self.l2.setFont(QFont('SansSerif', 15)) self.l3.setFont(QFont('SansSerif', 15)) self.link1 = QPushButton('MAIN PAGE', self) self.link1.move(0,70) self.link1.resize(200, 60) self.link1.clicked.connect(self.on_click1) self.link2= QPushButton('Book Food', self) self.link2.move(200, 70) self.link2.resize(200, 60) self.link2= QPushButton('Settings', self) self.link2.move(400, 70) self.link2.resize(200, 60) self.link2.clicked.connect(self.on_click2) self.f=QTextEdit(self) self.f.resize(100,200) self.f.move(10,200) self.h=QTextEdit(self) self.h.resize(100,200) self.h.move(210,200) self.p=QTextEdit(self) self.p.resize(100,200) self.p.move(350,200) self.amn1=QLabel("The Final Amount is :",self) self.amn1.resize(150,50) self.amn1.move(200,400) self.amn=QLabel(self) self.amn.move(400,410) self.amn.setFont(QFont('SansSerif', 15)) self.amn1.setFont(QFont('SansSerif', 10)) mycu.execute("SELECT * FROM "+self.a+"") res = mycu.fetchall() for row in res: self.c=QTextCursor(self.f.document()) self.c.insertText(str(row[0] +"\n")) for row in res: self.c=QTextCursor(self.h.document()) self.c.insertText(str(row[1] +"\n")) self.am=0 for row in res: self.c=QTextCursor(self.p.document()) self.c.insertText((str(row[2]) +"\n")) for row in res: self.am=int(self.am)+int(row[2]) self.amn.setText(str(self.am)) # Create a button in the window self.reg = QPushButton('Book', self) self.reg.move(100, 450) self.reg.clicked.connect(self.on_click3) self.show() def on_click1(self): from main import App self.m=App(self.a) self.m.show() self.close() def on_click2(self): from setting import App self.m=App(self.a) self.m.show() self.close() def on_click3(self): #database connection conn = mysql.connector.connect(host="localhost", user="******", passwd="", database="mini") mycu = conn.cursor() mycu.execute("TRUNCATE "+self.a+"") QMessageBox.question(self, 'Food', 'Foods Booked') from main import App self.m=App(self.a) self.m.show() self.close()
# # -*- coding: utf-8 -*- # pylint: disable=W0611,C0301 # @author Vangelis Banos """Code to run the web server""" from main import App from etc import settings if __name__ == '__main__': App.run(port=settings.PORT, debug=settings.DEBUG)
def on_click2(self): from setting import App self.m=App(self.a) self.m.show() self.close()
def on_click1(self): from main import App self.m=App(self.a) self.m.show() self.close()
def on_click1(self): from main import App self.m=App(self.a) self.m.show() self.close() def on_click2(self): from setting import App self.m=App(self.a) self.m.show() self.close() def on_click3(self): #database connection conn = mysql.connector.connect(host="localhost", user="******", passwd="", database="mini") mycu = conn.cursor() mycu.execute("TRUNCATE "+self.a+"") QMessageBox.question(self, 'Food', 'Foods Booked') from main import App self.m=App(self.a) self.m.show() self.close() if __name__ == '__main__': app = QApplication(sys.argv) ex = App() sys.exit(app.exec_())
fontSize, bold, color = 10, False, QColor(0, 0, 0) self.setFlags(self.flags() | Qt.ItemIsAutoTristate | Qt.ItemIsUserCheckable) elif itemType == 'provider': fontSize, bold, color = 10, False, QColor(0, 0, 0) self.setFlags(self.flags() | Qt.ItemIsAutoTristate | Qt.ItemIsUserCheckable) elif itemType == 'family': fontSize, bold, color = 10, False, QColor(0, 0, 0) self.setFlags(self.flags() | Qt.ItemIsUserCheckable) fnt = QFont('Arial', fontSize) fnt.setBold(bold) self.setFont(0, fnt) self.setForeground(0, color) # TODO: Problem with tray icon is that it dies when the main window is closed with X or something else, so need to bind it to something else? # class TrayIcon(QSystemTrayIcon): # def __init__(self, iconPath, app=None): # super().__init__(QIcon(iconPath)) # self.app = app # menu = QMenu() # exitAction = menu.addAction("Exit") # exitAction.triggered.connect(self.app.close) # self.setContextMenu(menu) if __name__ == '__main__': from main import App app = App() x = GUI(app) x.initUI()