def log(self): self.loc = self.loc_box.get() self.data = [ (self.ln_boxes[x].get(), self.pn_boxes[x].get(), self.desc_boxes[x].get()) for x in range(self.num_entries) if self.ln_boxes[x].get() != "" and self.pn_boxes[x].get() != "" ] # print self.data # for debugging conn = sql.connect(filename) curs = conn.cursor() for x in self.data: # check if the lot number is already in the database, if it is, don't add a second one, just update where it is. curs.execute("SELECT * FROM items WHERE lot_number=?", (x[0],)) if curs.fetchone() is None: curs.execute( "INSERT INTO items (lot_number,part_number,location,overstock,description) VALUES (?,?,?,,?)", (x[0], x[1], self.loc, 0, x[2]), ) else: curs.execute("UPDATE items SET location=? WHERE lot_number=?", (self.loc, x[0])) conn.commit() conn.close() self.master.destroy() main.go()
def daemonize(squadron_dir, config_file, polltime, repo, node_name, exit_loop=threading.Event()): """ Runs squadron every polltime minutes. Keyword arguments: squadron_dir -- squadron directory config_file -- config file or None for defaults polltime -- minutes to sleep in between runs repo -- source code for the squadron_dir for updating node_name -- override for nodename loglevel -- how much to log """ log.debug('entering daemon.daemonize %s', [squadron_dir, config_file, polltime, repo]) first_squadron_dir = main.get_squadron_dir(squadron_dir, None) parsed_config = parse_config(first_squadron_dir, log, config_file) print "Daemon is using loglevel: " + str(log.getEffectiveLevel()) if not polltime: polltime = float(parsed_config['polltime']) else: polltime = float(polltime) squadron_dir = main.get_squadron_dir(squadron_dir, parsed_config) log.info('Using Squadron dir: %s', squadron_dir) if not os.path.exists(squadron_dir): log.info('Cloning %s into %s', repo, squadron_dir) repo = Repo.clone_from(repo, squadron_dir) else: repo = Repo(squadron_dir) wakeup = threading.Event() webhook_thread = None if 'webhook' in parsed_config: run_webhook = parsed_config['webhook'] if bool(run_webhook): user = parsed_config['webhook_username'] password = parsed_config['webhook_password'] app = notify.webhook.WebHookHandler(user, password, lambda x: wakeup.set(), log) listen = parsed_config['webhook_listen'] port = parsed_config['webhook_port'] webhook_thread, webhook_server = notify.server.get_server(listen, port, app.application) log.info('Starting webhook server on %s:%s', listen, port) webhook_thread.start() while not exit_loop.is_set(): start_time = time.time() try: git = repo.git log.debug('Doing git pull --rebase') out = git.pull('--rebase') log.debug('Git pull returned: %s', out) ret = main.go(squadron_dir, node_name=node_name, config_file=config_file, dry_run=False) except Exception as e: log.exception('Caught top level exception') end_time = time.time() log.debug('daemon is sleeping: %s', polltime) if end_time - start_time < 60: # Don't wake up too often wakeup.clear() if wakeup.wait(polltime): log.debug('Woken up early') wakeup.clear() if webhook_thread: log.info('Stopping webhook server') webhook_server.stop() log.debug('Joining webhook server thread') webhook_thread.join() log.info('Stopped webhook server')
def daemonize(squadron_dir, config_file, polltime, repo, node_name, exit_loop=threading.Event()): """ Runs squadron every polltime minutes. Keyword arguments: squadron_dir -- squadron directory config_file -- config file or None for defaults polltime -- seconds to sleep in between runs repo -- source code for the squadron_dir for updating node_name -- override for nodename loglevel -- how much to log """ log.debug('entering daemon.daemonize %s', [squadron_dir, config_file, polltime, repo]) first_squadron_dir = main.get_squadron_dir(squadron_dir, None) parsed_config = parse_config(first_squadron_dir, log, config_file) print "Daemon is using loglevel: " + str(log.getEffectiveLevel()) if not polltime: polltime = float(parsed_config['polltime']) else: polltime = float(polltime) squadron_dir = main.get_squadron_dir(squadron_dir, parsed_config) log.info('Using Squadron dir: %s', squadron_dir) if not os.path.exists(squadron_dir): log.info('Cloning %s into %s', repo, squadron_dir) repo = Repo.clone_from(repo, squadron_dir) else: repo = Repo(squadron_dir) wakeup = threading.Event() webhook_thread = None if 'webhook' in parsed_config: run_webhook = parsed_config['webhook'] if bool(run_webhook): user = parsed_config['webhook_username'] password = parsed_config['webhook_password'] app = notify.webhook.WebHookHandler(user, password, lambda x: wakeup.set(), log) listen = parsed_config['webhook_listen'] port = parsed_config['webhook_port'] webhook_thread, webhook_server = notify.server.get_server( listen, port, app.application) log.info('Starting webhook server on %s:%s', listen, port) webhook_thread.start() while not exit_loop.is_set(): start_time = time.time() try: git = repo.git log.debug('Doing git pull --rebase') out = git.pull('--rebase') log.debug('Git pull returned: %s', out) ret = main.go(squadron_dir, node_name=node_name, config_file=config_file, dry_run=False, dont_rollback=True) except Exception as e: log.exception('Caught top level exception') end_time = time.time() log.debug('daemon is sleeping: %s', polltime) if end_time - start_time < 60: # Don't wake up too often wakeup.clear() if wakeup.wait(polltime): log.debug('Woken up early') wakeup.clear() if webhook_thread: log.info('Stopping webhook server') webhook_server.stop() log.debug('Joining webhook server thread') webhook_thread.join() log.info('Stopped webhook server')
# (c) Copyright 2018 by Coinkite Inc. This file is part of Coldcard <coldcardwallet.com> # and is covered by GPLv3 license found in COPYING. # # Code for the simulator to run, to get it to the point where main.py is called # on real system. Equivilent to a few lines of code found in stm32/COLDCARD/initfs.c import machine, pyb, sys, os if '--metal' in sys.argv: # next in argv will be two open file descriptors to use for serial I/O to a real Coldcard import bare_metal _n = sys.argv.index('--metal') + 1 bare_metal.start(*(int(sys.argv[a]) for a in [_n, _n + 1])) del _n, bare_metal if '--sflash' not in sys.argv: import nvstore from sim_settings import sim_defaults nvstore.SettingsObject.default_values = lambda _: dict(sim_defaults) if sys.argv[-1] != '-q': from main import go import sim_quickstart go() # EOF
def restart(root=None): if hasattr(root,"destroy"): root.destroy() main.go()
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = 'ipetrash' from main import go, show_test_calc show_test_calc() expression = '3,14159265358979323846264338327950288419716939937510582097494459230781640628620' \ '8998628034825342117067982148086513282306647093844609550582231725359408128481117' go(expression)
# In case you want the MAC address, here it is macaddr = ubinascii.hexlify(wlan.config('mac'), ':').decode() print("Device MAC:", macaddr) else: wlan, wconfig = None, None # Ok, give even a little more time for things to settle before # we move on to main.py time.sleep(2) # Pack up the wireless info so we can pass it around wlconfig = {"wlan": wlan, "wconfig": wconfig} gc.collect() return config, wlconfig if __name__ == "__main__": config, wlconfig = init() deviceid = config['deviceid'] if main is not None: if config['knownaps'] is not None and config['dbconfig'] is not None: main.go(deviceid, config, wlconfig, loops=25) else: print("WiFi and database configurations are null.") print("Aborting main loop start!") else: print("No main() found! Is that what you meant to do?")
def test_empty(): with pytest.raises(ValueError, match="Text is empty. Abort encoding."): go("")
def test_encoding(text, expected_encoded): encoded_text, _ = go(text) assert encoded_text == expected_encoded
def test_loss(text): _, decoded_text = go(text) assert decoded_text == text
def test_go(self): """ Test that it all works and writes out the file. """ # deck_filename = 'Test_deck_string_methods' deck_filename = 'Test deck (string methods)' main.go(deck_filename, self.url) self.assertTrue(os.path.exists(deck_filename + '.apkg'))
def reset(master): master.destroy() main.go()
#-*-coding:utf-8-*- from main import go if __name__ == '__main__': # singer={'name':'jaychou','singermid':'0025NhlN2yWrP4'} # singer = {'name': 'tfboys', 'singermid': '000zmpju02bEBm'} # singer = {'name': 'Joker', 'singermid': '002J4UUk29y8BY'} singer = {'name': 'Eason', 'singermid': '003Nz2So3XXYek'} go(singer)
import main feed='http://gtfs.s3.amazonaws.com/bart-archiver_20140109_0110.zip' in_dbhost='funicular2.crlfdv1vx6e1.us-east-1.rds.amazonaws.com' in_dbname='gtfs_engine' in_username='******' in_password = '******' short_agency_name_no_spaces='BART' main.go(feed,in_dbhost,in_dbname,in_username,in_password,short_agency_name_no_spaces)
def go_back(master): if hasattr(master,"destroy"): master.destroy() main.go()
fatal(f'given pattern file does not exist') tests = [f for f in slices_path.iterdir()] tests.sort() passed = 0 failed = [] for test_dir in tests: ast_path = get_ast_filepath(test_dir) out_path = get_out_filepath(test_dir) if out_path.exists(): out_path.unlink() try: go(ast_path, pattern_path) result = verify_output(test_dir) except: result = ERROR report_result(test_dir, result) if result == PASSED: passed += 1 else: failed.append(test_dir) print(f"Passed {passed}/{len(tests)} ({100*passed/len(tests)}%)") for f in failed: print(f)