コード例 #1
0
def main():
    global column_query_result, num_columns, column_names
    db = DB(LINK_HEADERS.DB_HOST, LINK_HEADERS.DB_USER,
            LINK_HEADERS.DB_PASSWORD, LINK_HEADERS.DB_NAME)
    result = db.get_stock_symbols()
    l = create_result_list(result)
    column_query_result = db.get_column_names()
    num_columns = len(column_query_result)
    column_names = str(column_query_result).strip("[]")
    column_names = column_names.replace("'", "")
    #print column_names
    opening_time = "13:30:00"
    closing_time = "20:00:00"
    while True:
        current_time = datetime.utcnow().strftime("%H:%M:%S")
        start = time.time()
        if current_time > opening_time and current_time < closing_time:
            yql = YQLQuery()
            print "request: " + str(current_time)
            request_yql(l, yql, db)
            update.main()
            algorithm.main()
            runtime = time.time() - start
            if runtime < 252:
                sleeptime = 252 - runtime
                time.sleep(sleeptime)
        else:
            exit()
コード例 #2
0
    def test_missing_settings(self, download_data, push_data, read_settings):
        read_settings.return_value = (None, None)

        main()

        self.assertFalse(download_data.called)
        self.assertFalse(push_data.called)
コード例 #3
0
def main(): 
    global column_query_result, num_columns, column_names
    db = DB(LINK_HEADERS.DB_HOST, LINK_HEADERS.DB_USER, LINK_HEADERS.DB_PASSWORD, LINK_HEADERS.DB_NAME)
    result = db.get_stock_symbols()
    l = create_result_list(result)
    column_query_result=db.get_column_names()
    num_columns=len(column_query_result)
    column_names=str(column_query_result).strip("[]")
    column_names=column_names.replace("'","")
    #print column_names 
    opening_time = "13:30:00"
    closing_time = "20:00:00"
    while True:
        current_time = datetime.utcnow().strftime("%H:%M:%S")
        start=time.time()
        if current_time > opening_time and current_time < closing_time:
            yql= YQLQuery()
            print "request: " + str(current_time)
            request_yql(l,yql,db)
            update.main()
            algorithm.main()
            runtime=time.time()-start
            if runtime < 252:
                sleeptime=252 - runtime
                time.sleep(sleeptime)
        else:
            exit()
コード例 #4
0
 def test_test_project(self):
     update.main(['--source', self.global_env.root, self.pbr.root])
     reqs = common._file_to_list(self.pbr.test_req_file)
     self.assertIn("testtools>=0.9.32", reqs)
     self.assertIn("testrepository>=0.0.17", reqs)
     # make sure we didn't add something we shouldn't
     self.assertNotIn("sphinxcontrib-pecanwsme>=0.2", reqs)
コード例 #5
0
def startup():
    os.system("resize -s 40 86")
    clear()
    print(line)
    core.randomlogo()
    print(line + "\n")
    core.textlogo()
    print(blue + " [+] Checking for updates..." + rr)

    # testing code{

    loc = get_install_location()
    print(blue + " [+] Checking for updater: " + rr + loc)
    sys.path.append(loc)
    try:
        import update
        update.main(force=False)
    except ImportError:
        print(red + "[!] Error importing update" + rr)

    # } testing code

    options()

    main()
コード例 #6
0
ファイル: test_update.py プロジェクト: ayasakov/requirements
    def test_verbose_output(self):
        capture = StringIO.StringIO()
        self.project = self.useFixture(common.project_fixture)
        update.main(
            ['--source', self.global_env.root, '-v', self.project.root],
            capture)
        expected = ("""Syncing %(project)s/requirements.txt
Version change for: greenlet, sqlalchemy, eventlet, pastedeploy, routes, webob, wsgiref, boto, kombu, pycrypto, python-swiftclient, lxml, jsonschema, python-keystoneclient\n"""  # noqa
            """Updated %(project)s/requirements.txt:
    greenlet>=0.3.1                ->   greenlet>=0.3.2
    SQLAlchemy>=0.7.8,<=0.7.99     ->   SQLAlchemy>=0.7,<=0.7.99
    eventlet>=0.9.12               ->   eventlet>=0.12.0
    PasteDeploy                    ->   PasteDeploy>=1.5.0
    routes                         ->   Routes>=1.12.3
    WebOb>=1.2                     ->   WebOb>=1.2.3,<1.3
    wsgiref                        ->   wsgiref>=0.1.2
    boto                           ->   boto>=2.4.0
    kombu>2.4.7                    ->   kombu>=2.4.8
    pycrypto>=2.1.0alpha1          ->   pycrypto>=2.6
    python-swiftclient>=1.2,<2     ->   python-swiftclient>=1.2
    lxml                           ->   lxml>=2.3
    jsonschema                     ->   jsonschema>=1.0.0,!=1.4.0,<2
    python-keystoneclient>=0.2.0   ->   python-keystoneclient>=0.4.1
Syncing %(project)s/test-requirements.txt
Version change for: mox, mox3, testrepository, testtools
Updated %(project)s/test-requirements.txt:
    mox==0.5.3                     ->   mox>=0.5.3
    mox3==0.7.3                    ->   mox3>=0.7.0
    testrepository>=0.0.13         ->   testrepository>=0.0.17
    testtools>=0.9.27              ->   testtools>=0.9.32
Syncing setup.py
""") % dict(project=self.project.root)
        self.assertEqual(expected, capture.getvalue())
コード例 #7
0
 def test_project(self):
     update.main(['--source', self.global_env.root, self.pbr.root])
     reqs = common._file_to_list(self.pbr.req_file)
     # ensure various updates take
     self.assertIn("jsonschema>=1.0.0,!=1.4.0,<2", reqs)
     self.assertIn("python-keystoneclient>=0.4.1", reqs)
     self.assertIn("SQLAlchemy>=0.7,<=0.7.99", reqs)
コード例 #8
0
ファイル: test_update.py プロジェクト: ayasakov/requirements
 def test_project_with_oslo(self):
     self.oslo_project = self.useFixture(common.oslo_fixture)
     update.main(
         ['--source', self.global_env.root, self.oslo_project.root])
     reqs = common._file_to_list(self.oslo_project.req_file)
     oslo_tar = ("-f http://tarballs.openstack.org/oslo.config/"
                 "oslo.config-1.2.0a3.tar.gz#egg=oslo.config-1.2.0a3")
     self.assertIn(oslo_tar, reqs)
コード例 #9
0
 def test_install_setup(self):
     project = self.useFixture(common.project_fixture)
     update.main(
         ['--source', self.global_env.root, '-o', 'global',
          project.root])
     setup_contents = common._file_to_list(project.setup_file)
     self.assertIn("# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO"
                   " - DO NOT EDIT", setup_contents)
コード例 #10
0
    def test_missing_command_line_argument(self, save):
        main()

        row = save.call_args[0][1]

        self.assertEquals(row['status'], 'error')
        self.assertEquals(row['rows_pushed'], 0)
        self.assertEquals(row['message'], 'No source dataset URL was supplied')
        self.assertIsInstance(row['date'], datetime.datetime)
コード例 #11
0
def first():
    try:
        tag = save_ma()
        tag.read()
    except:
        pass
    save_path = raw_input(
        "input you machine's save path (Example: /home/user/Document/) :")
    update.main(save_path)
コード例 #12
0
 def test_something(self, _input, _print):
     main()
     _input.assert_has_calls([
         call('Updating. Do not turn off your computer.'),
         call('0%'),
         call('58%'),
         call('100%'),
         call('DONE')
     ])
コード例 #13
0
 def run():
     # check update per day
     update_frequency = 60 * 60 * 24
     while True:
         try:
             update.main()
         except Exception as e:
             print(e)
         time.sleep(update_frequency)
コード例 #14
0
 def test_project(self):
     project = self.useFixture(common.project_fixture)
     update.main(
         ['--source', self.global_env.root, '-o', 'global',
          project.root])
     reqs = common._file_to_list("%s.%s" % (project.req_file, 'global'))
     # ensure various updates take
     self.assertIn("jsonschema>=1.0.0,!=1.4.0,<2", reqs)
     self.assertIn("python-keystoneclient>=0.4.1", reqs)
     self.assertIn("SQLAlchemy>=0.7,<=0.7.99", reqs)
コード例 #15
0
    def test_status_is_saved_to_sql_database(self, download_data, push_data, save, read_settings):
        url = 'http://performance.example.com'
        token = '6c32941c-7ce3-4d87-8f20-7598605c6142'

        read_settings.return_value = (url, token)

        main()

        download_data.assert_called_with('bar')
        push_data.assert_called_with(url, token, download_data.return_value)
        save.assert_called_with([], push_data.return_value)
コード例 #16
0
 def test_test_project(self):
     project = self.useFixture(common.project_fixture)
     update.main(
         ['--source', self.global_env.root, '-o', 'global',
          project.root])
     reqs = common._file_to_list(
         "%s.%s" % (project.test_req_file, 'global'))
     self.assertIn("testtools>=0.9.32", reqs)
     self.assertIn("testrepository>=0.0.17", reqs)
     # make sure we didn't add something we shouldn't
     self.assertNotIn("sphinxcontrib-pecanwsme>=0.2", reqs)
コード例 #17
0
ファイル: test_update.py プロジェクト: ayasakov/requirements
 def test_requirements_header(self):
     _REQS_HEADER = [
         '# The order of packages is significant, because pip processes '
         'them in the order',
         '# of appearance. Changing the order has an impact on the overall '
         'integration',
         '# process, which may cause wedges in the gate later.',
     ]
     self.project = self.useFixture(common.project_fixture)
     update.main(['--source', self.global_env.root, self.project.root])
     reqs = common._file_to_list(self.project.req_file)
     self.assertEqual(_REQS_HEADER, reqs[:3])
コード例 #18
0
    def update(self):
        update_py = os.path.realpath(
            os.path.join(os.path.dirname(__file__), '../update.py'))
        cmd = [update_py]
        if self.options.loglevel == logging.DEBUG:
            cmd.append("-d")
        sys.argv = cmd
        self.logger.info("update")
        if not self.options.dryrun:
            try:
                update.main()
            except SystemExit:
                return 1

        return 0
コード例 #19
0
ファイル: reset.py プロジェクト: hekar/Cahoots
def main():
    dbname = "postgres"
    username = "******"
    pgbin = os.getenv("pgbin")
    var = input("Are you sure you would like to reset the database? (Y/N)  ")
    
    if var.startswith("y") or var.startswith("Y"):
        try:
            print("Dropping Database...")
            subprocess.call([pgbin + "/psql.exe", "--dbname=" + dbname, "--username="******"--tuples-only", "--no-align", "--command=""DROP DATABASE cahoots"""], stdout=subprocess.PIPE)
            print("Creating Database...")
            subprocess.call([pgbin + "/psql.exe", "--dbname=" + dbname, "--username="******"--tuples-only", "--no-align", "--command=""\i ./versions/create.sql"""], stdout=subprocess.PIPE)
            print ("Running Updater...")
            update.main()
        except:
            print("An Error Occured!")
コード例 #20
0
def _update():
    import update
    data = update.main(request.values)
    response = app.response_class(
        response=data,
        status=200,
        mimetype='text/plain'
    )
    return response
コード例 #21
0
ファイル: main.py プロジェクト: marmotcai/qas
def main(cmd, argv):
    if len(cmd) > 0:  # 用进程方式启动
        my_tools.process(cmd, argv).start()
        return
    try:
        options, args = getopt.getopt(argv, "hvuis:t:d:m:p:e:", [
            "help", "version", "update", "initialize", "service=", "test=",
            "download=", "modeling=", "evaluation=", "predict="
        ])
    except getopt.GetoptError:
        sys.exit()

    for name, value in options:
        if name in ("-h", "--help"):
            usage()
        if name in ("-v", "--version"):
            my_tools.print_sys_info()
            ta.g.print_current_env_nformation()
        if name in ("-u", "--update"):
            update.main(argv)
        if name in ("-i", "--initialize"):
            g_man.main(argv)
        if name in ("-s", "--service"):
            platform = my_tools.UsePlatform()
            if ("windows" == platform.lower()):
                print(
                    "windows platform is not suppor daemon mode and run service mode"
                )
                service("")
            else:
                cmdstr = sys.executable + " daemon_main.py " + value
                print(cmdstr)
                os.system(cmdstr)
        if name in ("-t", "--test"):
            g_man.test(value)
        if name in ("-d", "--download"):
            g_dm.main(argv)
        if name in ("-m", "--modeling"):
            g_man.main(argv)
        if name in ("-p", "--predict"):
            g_man.main(argv)
        if name in ("-e", "--evaluation"):
            g_man.evaluation(value)
コード例 #22
0
ファイル: start_ota.py プロジェクト: szafranski/RH-ota
def main():
    old_python_error_message = """

The program detected that you are using python version 3.5 or lower.
This software requires python 3.6 or higher. You can manually update apt sources
for your OS - that process is described with details in the file
'~/RH-ota/docs/python36help.txt' - check here or on the GitHub repo page.

You could also just burn SD-Card with Raspbian Buster (10) or newer since those
support python 3.6+ natively. Using newer OS is advised anyways.

To check currently used Raspbian OS version - type: 'cat /etc/os-release'
To check currently used python3 version - type: 'python3 --version'
To list all python versions installed on your OS - type: 'python' and hit Tab twice
"""
    if sys.version_info < (3, 6):
        print(2 * "\n" + 80 * "-" + "\n" + 80 * "-")
        print("\n\nThis program requires python3.6 or newer")
        print(old_python_error_message)
    else:
        print("Program starts...")
        import update
        update.main()
コード例 #23
0
 def test_install_setup(self):
     update.main(['--source', self.global_env.root, self.pbr.root])
     setup_contents = common._file_to_list(self.pbr.setup_file)
     self.assertNotIn("# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS "
                      "REPO - DO NOT EDIT", setup_contents)
コード例 #24
0
ファイル: test_update.py プロジェクト: ayasakov/requirements
 def test_requirement_not_in_global(self):
     self.bad_project = self.useFixture(common.bad_project_fixture)
     with testtools.ExpectedException(Exception):
         update.main(
             ['--source', self.global_env.root, self.bad_project.root])
コード例 #25
0
ファイル: test_update.py プロジェクト: ayasakov/requirements
 def test_requirement_soft_update(self):
     self.bad_project = self.useFixture(common.bad_project_fixture)
     update.main([
         '-s', '--source', self.global_env.root, self.bad_project.root])
     reqs = common._file_to_list(self.bad_project.req_file)
     self.assertIn("thisisnotarealdepedency", reqs)
コード例 #26
0
ファイル: test_update.py プロジェクト: ayasakov/requirements
 def test_requirement_not_in_global_non_fatal(self):
     self.useFixture(
         fixtures.EnvironmentVariable("NON_STANDARD_REQS", "1"))
     self.bad_project = self.useFixture(common.bad_project_fixture)
     update.main(['--source', self.global_env.root, self.bad_project.root])
コード例 #27
0
    )

    update.run_tests()

    print update.run_tests.output


################################################################################

opt_parser = optparse.OptionParser()

opt_parser.add_option('-c', '--config', action='store_true')
opt_parser.add_option('-s', '--skip_svn', action='store_true')
opt_parser.add_option('-f', '--force_build', action='store_true')
opt_parser.add_option('-t', '--test', action='store_true')

if __name__ == '__main__':
    options, args = opt_parser.parse_args()
    sys.argv = sys.argv[:1] + args

    if options.skip_svn: skip_svn()
    if options.force_build: force_build()

    if options.test:
        run_tests()
    else:
        # Swap out some slow components for quick debugging
        if options.config: config.main()
        else: update.main()

################################################################################
コード例 #28
0
def homepage():

    print("[", current_time, "]",
          " ====Toolscript===")  # Print the time & a title

    greetings = (input("""                                  
--------------------------------------------------------------------------------------------------    
| [1] Call calculator             [6] Portscanning                                                |
| [2] Call password generator     [7] Install RPi software: Apache, MariaDB, PHP                 |
| [3] Show IP                     [8] GPIO pin state                                              |
| [4] system info                 [9] Exit                                                        |
| [5] Update & upgrade RPi                                                                        |
--------------------------------------------------------------------------------------------------\n"""
                       ))

    if greetings == "1":
        rekentoestel.main()  # Run the calculator script
        time.sleep(1)
        print("")
        homepage()  # Go back to the main menu

    elif greetings == "2":
        password.main()
        time.sleep(1)
        print("")
        homepage()

    elif greetings == "3":
        IP.get_Host_name_IP()
        time.sleep(1)
        print("")
        homepage()

    elif greetings == "4":
        system.sys_information()
        time.sleep(1)
        print("")
        homepage()

    elif greetings == "5":
        update.main()
        print("")
        homepage()

    elif greetings == "6":
        Portscan.main()
        print("")
        homepage()

    elif greetings == "7":
        InstallSoftware.main()
        print("")
        homepage()

    elif greetings == "8":
        Pinstatus.main()
        print("")
        homepage()

    elif greetings == "9":
        print("See you next time!")
        sys.exit(0)

    elif greetings != "1" or "2" or "3" or "4" or "5" or "6" or "7" or "8" or "9":  # error message
        print("Error! Try again")
        time.sleep(1)
        print("")
        print("")
        homepage()
コード例 #29
0
def sincronizar(hora_sincronizar):

    print('Actualizando Base de Datos...')
    main()
    print('Base de Datos Actualizada')
    print(f'La Base de Datos sera Actualizada a las {hora_sincronizar}')
コード例 #30
0
ファイル: mocks.py プロジェクト: Anugrahaa/anagrammatic
        install_env      =    os.environ.copy(),
    )

    update.run_tests()
    
    print update.run_tests.output

################################################################################

opt_parser = optparse.OptionParser()

opt_parser.add_option('-c', '--config',      action = 'store_true')
opt_parser.add_option('-s', '--skip_svn',    action = 'store_true')
opt_parser.add_option('-f', '--force_build', action = 'store_true')
opt_parser.add_option('-t', '--test',  action = 'store_true')

if __name__ == '__main__':
    options, args = opt_parser.parse_args()
    sys.argv = sys.argv[:1] + args
    
    if options.skip_svn:     skip_svn()
    if options.force_build:  force_build()
    
    if options.test:
        run_tests()
    else:
        # Swap out some slow components for quick debugging
        if options.config: config.main()
        else:              update.main()
    
################################################################################
コード例 #31
0
def main(ctrl, opts):

    if opts.help_type:
        info = getChannelInfo(opts.help_type)
        print _("Type:"), opts.help_type, "-", info.name
        print
        print info.description.strip()
        print
        print _("Fields:")
        print format_fields(info.fields)
        print
        print _("(*) These fields are necessary for this type.")
        print
        sys.exit(0)

    if (sysconf.getReadOnly() is True and opts.list is None and
                              opts.show is None and opts.yaml is None):
        iface.warning(_("Can't edit channels information."))
        raise Error, _("Configuration is in readonly mode.")
    
    if opts.add is not None:
        if not opts.add and opts.args == ["-"]:
            newchannels = []
            data = sys.stdin.read()
            descriptions = parseChannelsDescription(data)
            for alias in descriptions:
                channel = descriptions[alias]
                channel["alias"] = alias
                newchannels.append(channel)
        elif len(opts.add) == 1:
            arg = opts.add[0]
            if os.path.isdir(arg):
                sysconf.set("default-localmedia", arg, soft=True)
                newchannels = detectLocalChannels(arg)
            elif os.path.isfile(arg):
                newchannels = []
                data = open(arg).read()
                descriptions = parseChannelsDescription(data)
                for alias in descriptions:
                    channel = descriptions[alias]
                    channel["alias"] = alias
                    newchannels.append(channel)
            elif ":/" in arg:
                succ, fail = ctrl.downloadURLs([arg], "channel description")
                if fail:
                    raise Error, _("Unable to fetch channel description: %s")\
                                 % fail[arg]
                data = open(succ[arg]).read()
                if succ[arg].startswith(sysconf.get("data-dir")):
                    os.unlink(succ[arg])
                newchannels = []
                descriptions = parseChannelsDescription(data)
                for alias in descriptions:
                    channel = descriptions[alias]
                    channel["alias"] = alias
                    newchannels.append(channel)
            else:
                raise Error, _("File not found: %s") % arg
        elif opts.add:
            alias = opts.add.pop(0).strip()
            if not alias:
                raise Error, _("Channel has no alias")
            channel = {}
            for arg in opts.add:
                if "=" not in arg:
                    raise Error, _("Argument '%s' has no '='") % arg
                key, value = arg.split("=", 1)
                channel[key.strip()] = value.strip()
            channel = parseChannelData(channel)
            channel["alias"] = alias
            newchannels = [channel]
        else:
            raise Error, _("Channel information needed")

        newaliases = []
        for channel in newchannels:
            type = channel.get("type")
            if not opts.yes:
                info = getChannelInfo(type)
                print
                for key, label, ftype, default, descr in info.fields:
                    if key in channel:
                        print "%s: %s" % (label, channel[key])
                print
            if opts.yes or iface.askYesNo(_("Include this channel?")):
                try:
                    createChannel("alias", channel)
                except Error, e:
                    raise
                else:
                    try:
                        alias = channel.get("alias")
                        while not alias or sysconf.has(("channels", alias)):
                            if alias:
                                print _("Channel alias '%s' is already in "
                                        "use.") % alias
                            alias = raw_input(_("Channel alias: ")).strip()
                        del channel["alias"]
                        sysconf.set(("channels", alias), channel)
                        newaliases.append(alias)
                    except KeyboardInterrupt:
                        print

        removable = [alias for alias in newaliases
                     if sysconf.get(("channels", alias, "removable"))]
        if removable:
            print
            print _("Updating removable channels...")
            print
            import update
            updateopts = update.parse_options(removable)
            update.main(ctrl, updateopts)
コード例 #32
0
ファイル: views.py プロジェクト: danielcorin/danielcorin.com
def call_update():
	hud = update.main()
	a = APIData(api_string=json.dumps(hud))
	a.save()
	convert_times(hud)
	return hud
コード例 #33
0
ファイル: download_objdump.py プロジェクト: nageshlop/proxy-1
#!/usr/bin/env python
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import sys

import update

# TODO(hans): Remove this forwarding hack after all callers of this script have
# been updated to call update.py instead.
if __name__ == '__main__':
    sys.argv = [sys.argv[0], '--package=objdump']
    sys.exit(update.main())
コード例 #34
0
def upd(arg):
    update.main(source=arg, filename="bot.py", pre_boot=shutdown)
コード例 #35
0
    db = client.get_default_database()

    members = db.members

    data = []

    for mem in members.find():
        data.append(mem)

    data = sorted(data, key=lambda k: k['totalCommits'])

    return data[::-1]


app = Flask(__name__, static_url_path='/static')


@app.route("/")
def index():
    content = getContent()
    total = sum([x['totalCommits'] for x in content])
    return render_template('index.html', context=content, totalC=total)


if __name__ == '__main__':
    if sys.argv and '--update' in sys.argv:
        update.main()
    port = int(os.environ.get('PORT', 5000))
    http_server = WSGIServer(('', port), app)
    http_server.serve_forever()
コード例 #36
0
ファイル: main.py プロジェクト: apwest/monkey-business
    def get(self):
        update.main()

        self.response.headers['Content-Type'] = 'application/json'
        self.response.write(json.dumps({"status": "200"}))