def update_output(): # Init db_utils.create_db() #db_utils.get_tasks_info() json_every_task() html_every_task() # Render to image http://stackoverflow.com/questions/2192799/html-to-image-in-javascript-or-python subprocess.check_call(['phantomjs', 'generate_image.js', 'html/'])
def before_all(context): """Set env parameters.""" os.environ['LINES'] = "100" os.environ['COLUMNS'] = "100" os.environ['EDITOR'] = 'ex' context.package_root = os.path.abspath( os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) os.environ["COVERAGE_PROCESS_START"] = os.path.join(context.package_root, '.coveragerc') context.exit_sent = False vi = '_'.join([str(x) for x in sys.version_info[:3]]) db_name = context.config.userdata.get( 'my_test_db', None) or "mycli_behave_tests" db_name_full = '{0}_{1}'.format(db_name, vi) # Store get params from config/environment variables context.conf = { 'host': context.config.userdata.get( 'my_test_host', os.getenv('PYTEST_HOST', 'localhost') ), 'user': context.config.userdata.get( 'my_test_user', os.getenv('PYTEST_USER', 'root') ), 'pass': context.config.userdata.get( 'my_test_pass', os.getenv('PYTEST_PASSWORD', None) ), 'cli_command': context.config.userdata.get( 'my_cli_command', None) or sys.executable + ' -c "import coverage ; coverage.process_startup(); import mycli.main; mycli.main.cli()"', 'dbname': db_name, 'dbname_tmp': db_name_full + '_tmp', 'vi': vi, 'pager_boundary': '---boundary---', } _, my_cnf = mkstemp() with open(my_cnf, 'w') as f: f.write( '[client]\n' 'pager={0} {1} {2}\n'.format( sys.executable, os.path.join(context.package_root, 'test/features/wrappager.py'), context.conf['pager_boundary']) ) context.conf['defaults-file'] = my_cnf context.cn = dbutils.create_db(context.conf['host'], context.conf['user'], context.conf['pass'], context.conf['dbname']) context.fixture_data = fixutils.read_fixture_files()
def before_all(context): """ Set env parameters. """ os.environ['LINES'] = "100" os.environ['COLUMNS'] = "100" os.environ['PAGER'] = 'cat' os.environ['EDITOR'] = 'nano' context.exit_sent = False vi = '_'.join([str(x) for x in sys.version_info[:3]]) db_name = context.config.userdata.get('pg_test_db', None) db_name_full = '{0}_{1}'.format(db_name, vi) # Store get params from config. context.conf = { 'host': context.config.userdata.get('pg_test_host', 'localhost'), 'user': context.config.userdata.get('pg_test_user', 'postgres'), 'pass': context.config.userdata.get('pg_test_pass', None), 'dbname': db_name_full, 'dbname_tmp': db_name_full + '_tmp', 'vi': vi } # Store old env vars. context.pgenv = { 'PGDATABASE': os.environ.get('PGDATABASE', None), 'PGUSER': os.environ.get('PGUSER', None), 'PGHOST': os.environ.get('PGHOST', None), 'PGPASS': os.environ.get('PGPASS', None), } # Set new env vars. os.environ['PGDATABASE'] = context.conf['dbname'] os.environ['PGUSER'] = context.conf['user'] os.environ['PGHOST'] = context.conf['host'] if context.conf['pass']: os.environ['PGPASS'] = context.conf['pass'] else: if 'PGPASS' in os.environ: del os.environ['PGPASS'] if 'PGHOST' in os.environ: del os.environ['PGHOST'] context.cn = dbutils.create_db(context.conf['host'], context.conf['user'], context.conf['pass'], context.conf['dbname']) context.fixture_data = fixutils.read_fixture_files()
def before_all(context): """ Set env parameters. """ os.environ["LINES"] = "100" os.environ["COLUMNS"] = "100" os.environ["PAGER"] = "cat" os.environ["EDITOR"] = "nano" context.exit_sent = False vi = "_".join([str(x) for x in sys.version_info[:3]]) db_name = context.config.userdata.get("pg_test_db", None) db_name_full = "{0}_{1}".format(db_name, vi) # Store get params from config. context.conf = { "host": context.config.userdata.get("pg_test_host", "localhost"), "user": context.config.userdata.get("pg_test_user", "postgres"), "pass": context.config.userdata.get("pg_test_pass", None), "dbname": db_name_full, "dbname_tmp": db_name_full + "_tmp", "vi": vi, } # Store old env vars. context.pgenv = { "PGDATABASE": os.environ.get("PGDATABASE", None), "PGUSER": os.environ.get("PGUSER", None), "PGHOST": os.environ.get("PGHOST", None), "PGPASS": os.environ.get("PGPASS", None), } # Set new env vars. os.environ["PGDATABASE"] = context.conf["dbname"] os.environ["PGUSER"] = context.conf["user"] os.environ["PGHOST"] = context.conf["host"] if context.conf["pass"]: os.environ["PGPASS"] = context.conf["pass"] else: if "PGPASS" in os.environ: del os.environ["PGPASS"] if "PGHOST" in os.environ: del os.environ["PGHOST"] context.cn = dbutils.create_db( context.conf["host"], context.conf["user"], context.conf["pass"], context.conf["dbname"] ) context.fixture_data = fixutils.read_fixture_files()
def before_all(context): """ Set env parameters. """ os.environ['LINES'] = "100" os.environ['COLUMNS'] = "100" os.environ['PAGER'] = 'cat' os.environ['EDITOR'] = 'nano' context.exit_sent = False vi = '_'.join([str(x) for x in sys.version_info[:3]]) db_name = context.config.userdata.get('pg_test_db', None) db_name_full = '{0}_{1}'.format(db_name, vi) # Store get params from config. context.conf = { 'host': context.config.userdata.get('pg_test_host', 'localhost'), 'user': context.config.userdata.get('pg_test_user', 'postgres'), 'pass': context.config.userdata.get('pg_test_pass', None), 'dbname': db_name_full, 'dbname_tmp': db_name_full + '_tmp', 'vi': vi } # Store old env vars. context.pgenv = { 'PGDATABASE': os.environ.get('PGDATABASE', None), 'PGUSER': os.environ.get('PGUSER', None), 'PGHOST': os.environ.get('PGHOST', None), 'PGPASS': os.environ.get('PGPASS', None), } # Set new env vars. os.environ['PGDATABASE'] = context.conf['dbname'] os.environ['PGUSER'] = context.conf['user'] os.environ['PGHOST'] = context.conf['host'] if context.conf['pass']: os.environ['PGPASS'] = context.conf['pass'] else: if 'PGPASS' in os.environ: del os.environ['PGPASS'] if 'PGHOST' in os.environ: del os.environ['PGHOST'] context.cn = dbutils.create_db(context.conf['host'], context.conf['user'], context.conf['pass'], context.conf['dbname']) context.fixture_data = fixutils.read_fixture_files()
def before_all(context): """Set env parameters.""" os.environ['LINES'] = "100" os.environ['COLUMNS'] = "100" os.environ['EDITOR'] = 'ex' os.environ["COVERAGE_PROCESS_START"] = os.getcwd() + "/../.coveragerc" context.exit_sent = False vi = '_'.join([str(x) for x in sys.version_info[:3]]) db_name = context.config.userdata.get('my_test_db', None) or "mycli_behave_tests" db_name_full = '{0}_{1}'.format(db_name, vi) # Store get params from config/environment variables context.conf = { 'host': context.config.userdata.get('my_test_host', os.getenv('PYTEST_HOST', 'localhost')), 'user': context.config.userdata.get('my_test_user', os.getenv('PYTEST_USER', 'root')), 'pass': context.config.userdata.get('my_test_pass', os.getenv('PYTEST_PASSWORD', None)), 'cli_command': context.config.userdata.get('my_cli_command', None) or sys.executable + ' -c "import coverage ; coverage.process_startup(); import mycli.main; mycli.main.cli()"', 'dbname': db_name, 'dbname_tmp': db_name_full + '_tmp', 'vi': vi, 'pager_boundary': '---boundary---', } os.environ['PAGER'] = "{0} {1} {2}".format(sys.executable, "test/features/wrappager.py", context.conf['pager_boundary']) context.cn = dbutils.create_db(context.conf['host'], context.conf['user'], context.conf['pass'], context.conf['dbname']) context.fixture_data = fixutils.read_fixture_files()
def before_all(context): """ Set env parameters. """ os.environ['LINES'] = "100" os.environ['COLUMNS'] = "100" os.environ['PAGER'] = 'cat' context.exit_sent = False # Store get params from config. context.conf = { 'host': context.config.userdata.get('pg_test_host', 'localhost'), 'user': context.config.userdata.get('pg_test_user', 'root'), 'pass': context.config.userdata.get('pg_test_pass', None), 'dbname': context.config.userdata.get('pg_test_db', None), } # Store old env vars. context.pgenv = { 'PGDATABASE': os.environ.get('PGDATABASE', None), 'PGUSER': os.environ.get('PGUSER', None), 'PGHOST': os.environ.get('PGHOST', None), 'PGPASS': os.environ.get('PGPASS', None), } # Set new env vars. os.environ['PGDATABASE'] = context.conf['dbname'] os.environ['PGUSER'] = context.conf['user'] os.environ['PGHOST'] = context.conf['host'] if context.conf['pass']: os.environ['PGPASS'] = context.conf['pass'] elif 'PGPASS' in os.environ: del os.environ['PGPASS'] context.cn = dbutils.create_db(context.conf['host'], context.conf['user'], context.conf['pass'], context.conf['dbname']) context.fixture_data = fixutils.read_fixture_files()
#!/home/common/scripts/python/bin/python3 import sqlite3 import db_utils as db class scheduleDB """Create schedule database object in memory.""" def __init__(self,schedule) self.db = db.create_db(schedule)
def before_all(context): """Set env parameters.""" env_old = copy.deepcopy(dict(os.environ)) os.environ['LINES'] = "100" os.environ['COLUMNS'] = "100" os.environ['PAGER'] = 'cat' os.environ['EDITOR'] = 'ex' os.environ['VISUAL'] = 'ex' context.package_root = os.path.abspath( os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) fixture_dir = os.path.join( context.package_root, 'tests/features/fixture_data') print('package root:', context.package_root) print('fixture dir:', fixture_dir) os.environ["COVERAGE_PROCESS_START"] = os.path.join(context.package_root, '.coveragerc') context.exit_sent = False vi = '_'.join([str(x) for x in sys.version_info[:3]]) db_name = context.config.userdata.get('pg_test_db', 'pgcli_behave_tests') db_name_full = '{0}_{1}'.format(db_name, vi) # Store get params from config. context.conf = { 'host': context.config.userdata.get( 'pg_test_host', os.getenv('PGHOST', 'localhost') ), 'user': context.config.userdata.get( 'pg_test_user', os.getenv('PGUSER', 'postgres') ), 'pass': context.config.userdata.get( 'pg_test_pass', os.getenv('PGPASSWORD', None) ), 'port': context.config.userdata.get( 'pg_test_port', os.getenv('PGPORT', '5432') ), 'cli_command': ( context.config.userdata.get('pg_cli_command', None) or '{python} -c "{startup}"'.format( python=sys.executable, startup='; '.join([ "import coverage", "coverage.process_startup()", "import pgcli.main", "pgcli.main.cli()"]))), 'dbname': db_name_full, 'dbname_tmp': db_name_full + '_tmp', 'vi': vi, 'pager_boundary': '---boundary---', } os.environ['PAGER'] = "{0} {1} {2}".format( sys.executable, os.path.join(context.package_root, "tests/features/wrappager.py"), context.conf['pager_boundary']) # Store old env vars. context.pgenv = { 'PGDATABASE': os.environ.get('PGDATABASE', None), 'PGUSER': os.environ.get('PGUSER', None), 'PGHOST': os.environ.get('PGHOST', None), 'PGPASSWORD': os.environ.get('PGPASSWORD', None), 'PGPORT': os.environ.get('PGPORT', None), 'XDG_CONFIG_HOME': os.environ.get('XDG_CONFIG_HOME', None), } # Set new env vars. os.environ['PGDATABASE'] = context.conf['dbname'] os.environ['PGUSER'] = context.conf['user'] os.environ['PGHOST'] = context.conf['host'] os.environ['PGPORT'] = context.conf['port'] if context.conf['pass']: os.environ['PGPASSWORD'] = context.conf['pass'] else: if 'PGPASSWORD' in os.environ: del os.environ['PGPASSWORD'] context.cn = dbutils.create_db(context.conf['host'], context.conf['user'], context.conf['pass'], context.conf['dbname'], context.conf['port']) context.fixture_data = fixutils.read_fixture_files() # use temporary directory as config home context.env_config_home = tempfile.mkdtemp(prefix='pgcli_home_') os.environ['XDG_CONFIG_HOME'] = context.env_config_home show_env_changes(env_old, dict(os.environ))
def before_all(context): """Set env parameters.""" env_old = copy.deepcopy(dict(os.environ)) os.environ["LINES"] = "100" os.environ["COLUMNS"] = "100" os.environ["PAGER"] = "cat" os.environ["EDITOR"] = "ex" os.environ["VISUAL"] = "ex" context.package_root = os.path.abspath( os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) fixture_dir = os.path.join(context.package_root, "tests/features/fixture_data") print("package root:", context.package_root) print("fixture dir:", fixture_dir) os.environ["COVERAGE_PROCESS_START"] = os.path.join( context.package_root, ".coveragerc") context.exit_sent = False vi = "_".join([str(x) for x in sys.version_info[:3]]) db_name = context.config.userdata.get("pg_test_db", "pgcli_behave_tests") db_name_full = "{0}_{1}".format(db_name, vi) # Store get params from config. context.conf = { "host": context.config.userdata.get("pg_test_host", os.getenv("PGHOST", "localhost")), "user": context.config.userdata.get("pg_test_user", os.getenv("PGUSER", "postgres")), "pass": context.config.userdata.get("pg_test_pass", os.getenv("PGPASSWORD", None)), "port": context.config.userdata.get("pg_test_port", os.getenv("PGPORT", "5432")), "cli_command": (context.config.userdata.get("pg_cli_command", None) or '{python} -c "{startup}"'.format( python=sys.executable, startup="; ".join([ "import coverage", "coverage.process_startup()", "import pgcli.main", "pgcli.main.cli()", ]), )), "dbname": db_name_full, "dbname_tmp": db_name_full + "_tmp", "vi": vi, "pager_boundary": "---boundary---", } os.environ["PAGER"] = "{0} {1} {2}".format( sys.executable, os.path.join(context.package_root, "tests/features/wrappager.py"), context.conf["pager_boundary"], ) # Store old env vars. context.pgenv = { "PGDATABASE": os.environ.get("PGDATABASE", None), "PGUSER": os.environ.get("PGUSER", None), "PGHOST": os.environ.get("PGHOST", None), "PGPASSWORD": os.environ.get("PGPASSWORD", None), "PGPORT": os.environ.get("PGPORT", None), "XDG_CONFIG_HOME": os.environ.get("XDG_CONFIG_HOME", None), "PGSERVICEFILE": os.environ.get("PGSERVICEFILE", None), } # Set new env vars. os.environ["PGDATABASE"] = context.conf["dbname"] os.environ["PGUSER"] = context.conf["user"] os.environ["PGHOST"] = context.conf["host"] os.environ["PGPORT"] = context.conf["port"] os.environ["PGSERVICEFILE"] = os.path.join(fixture_dir, "mock_pg_service.conf") if context.conf["pass"]: os.environ["PGPASSWORD"] = context.conf["pass"] else: if "PGPASSWORD" in os.environ: del os.environ["PGPASSWORD"] context.cn = dbutils.create_db( context.conf["host"], context.conf["user"], context.conf["pass"], context.conf["dbname"], context.conf["port"], ) context.fixture_data = fixutils.read_fixture_files() # use temporary directory as config home context.env_config_home = tempfile.mkdtemp(prefix="pgcli_home_") os.environ["XDG_CONFIG_HOME"] = context.env_config_home show_env_changes(env_old, dict(os.environ))
def before_all(context): """Set env parameters.""" os.environ['LINES'] = "100" os.environ['COLUMNS'] = "100" os.environ['EDITOR'] = 'ex' os.environ['LC_ALL'] = 'en_US.utf8' test_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) login_path_file = os.path.join(test_dir, 'mylogin.cnf') os.environ['MYSQL_TEST_LOGIN_FILE'] = login_path_file context.package_root = os.path.abspath( os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) os.environ["COVERAGE_PROCESS_START"] = os.path.join(context.package_root, '.coveragerc') context.exit_sent = False vi = '_'.join([str(x) for x in sys.version_info[:3]]) db_name = context.config.userdata.get( 'my_test_db', None) or "mycli_behave_tests" db_name_full = '{0}_{1}'.format(db_name, vi) # Store get params from config/environment variables context.conf = { 'host': context.config.userdata.get( 'my_test_host', os.getenv('PYTEST_HOST', 'localhost') ), 'user': context.config.userdata.get( 'my_test_user', os.getenv('PYTEST_USER', 'root') ), 'pass': context.config.userdata.get( 'my_test_pass', os.getenv('PYTEST_PASSWORD', None) ), 'cli_command': context.config.userdata.get( 'my_cli_command', None) or sys.executable + ' -c "import coverage ; coverage.process_startup(); import mycli.main; mycli.main.cli()"', 'dbname': db_name, 'dbname_tmp': db_name_full + '_tmp', 'vi': vi, 'pager_boundary': '---boundary---', } _, my_cnf = mkstemp() with open(my_cnf, 'w') as f: f.write( '[client]\n' 'pager={0} {1} {2}\n'.format( sys.executable, os.path.join(context.package_root, 'test/features/wrappager.py'), context.conf['pager_boundary']) ) context.conf['defaults-file'] = my_cnf context.conf['myclirc'] = os.path.join(context.package_root, 'test', 'myclirc') context.cn = dbutils.create_db(context.conf['host'], context.conf['user'], context.conf['pass'], context.conf['dbname']) context.fixture_data = fixutils.read_fixture_files()
import os import sys import requests from db_utils import select_all_tasks, create_db, change_settings from helpers import check_settings, get_index if not os.path.isfile('settings.db'): create_db('settings.db') settings = select_all_tasks('settings.db') check_settings(settings['language']) settings = select_all_tasks('settings.db') is_used = True token = settings['API_KEY'] url = settings['default_url'] headers = { 'Content-Type': 'application/json', 'Accept': 'application/json', 'Authorization': f"Token {token}", } language = settings["language"] while is_used: print('Введите желаемый адрес либо "0", если хотите изменить настройки: \n') inp = input() if inp == '0': language = change_settings(language) else: address = f'{{"query": "{inp}", "language": "{language}"}}'.encode('utf-8')
def init_db() -> None: create_db() create_user_table() create_meetings_table()
# Close archive myfile.close() # Find ZIPs and RARs in input directory for f in os.listdir(INPUT_PATH): if fnmatch.fnmatch(f, '*.[Zz][Ii][Pp]'): zips.append(f) if fnmatch.fnmatch(f, '*.[Cc][Bb][Zz]'): zips.append(f) if fnmatch.fnmatch(f, '*.[Rr][Aa][Rr]'): rars.append(f) if fnmatch.fnmatch(f, '*.[Cc][Bb][Rr]'): rars.append(f) # Check for existence of SQLite3 database, creating if necessary if not os.path.exists(DB_FILE): print "SQLite database not found, creating file " + DB_FILE + "...", create_db() print "done." # Scan and process ZIP files scan_archive_file(zips, 'zip') # Scan and process RAR files scan_archive_file(rars, 'rar')
# Validate limit try: limit = int(limit) print limit except: print "Limit is not a number" limit = 1 print "Limit set to default " + str(limit) if id is None and task is None: # Undo tasks (limited) with the newest date todo = 1 elif id is not None: # Undo registry with specified id todo = 1 elif task is not None: # Undo tasks (limited) with specified name with the newest date todo = 1 # clear command elif arguments['clear'] == True: try: db_utils.delete_db() db_utils.create_db() except: print "Failed cleaning db" # output command elif arguments['output'] == True: todo = 1