def main():
  vt_mysqlbinlog =  os.environ.get('VT_MYSQL_ROOT') + '/bin/vt_mysqlbinlog'
  if not os.path.isfile(vt_mysqlbinlog):
    sys.exit("%s is not present, please install it and then re-run the test" % vt_mysqlbinlog)

  print "Note: This is a slow test, has a couple of sleeps in it to simulate proper state changes"

  utils.main()
Example #2
0
def load():
	import base
	base.main(dp)
	import text_parse
	text_parse.main(dp)
	import utils
	utils.main(dp)
	import vortaro
	vortaro.main(dp)
	import xkcd
	xkcd.main(dp)
Example #3
0
def main(argv):
    load_all = True
    dump_all = True
    curr_frame = dict(start_day=1, start_hour=0,end_day=1,end_hour=1,year = 2009, month = 7)
    from config import update_time_frame
    try:
        opts, args = getopt.getopt(argv,"h",["sd=","sh=","ed=","eh="])
    except getopt.GetoptError:
        print 'driver-analysis --sd --sh --ed --eh '
        sys.exit(2)
    for opt, arg in opts:
        if opt == 'h':
            print 'driver-analysis --sd --sh --ed --eh '
            sys.exit()
        elif opt=="--sd":
            curr_frame["start_day"] = int(arg)
        elif opt=="--sh":
            curr_frame["start_hour"] = int(arg)
        elif opt=="--ed":
            curr_frame["end_day"] = int(arg)
        elif opt=="--eh":
            curr_frame["end_hour"] = int(arg)
    print curr_frame
#     time_frame_list = [dict(start_day=1, start_hour=0,end_day=1,end_hour=1,year = 2009, month = 7),
#                        dict(start_day=10, start_hour=0,end_day=11,end_hour=0,year = 2012, month = 4),
#                        dict(start_day=11, start_hour=0,end_day=12,end_hour=0,year = 2012, month = 4),
#                        dict(start_day=12, start_hour=0,end_day=13,end_hour=0,year = 2012, month = 4),
#                        dict(start_day=13, start_hour=0,end_day=14,end_hour=0,year = 2012, month = 4),
#                        dict(start_day=15, start_hour=0,end_day=16,end_hour=0,year = 2012, month = 4),
#                        ]
    update_time_frame(curr_frame)
    import utils
    utils.main()
    
    import grid
    grid.main(reload=load_all, dump=dump_all)
    
    import input_data
    # cProfile.run('input_data.main(reload_trip=load_all, reload_log=load_all, dump_trip=dump_all, dump_log=dump_all)')
    input_data.main(reload_trip=load_all, reload_log=load_all, dump_trip=dump_all, dump_log=dump_all)
     
    import driver_income
    driver_income.main(reload=load_all, dump=dump_all)
     
    import driver_state_stats
    driver_state_stats.main(reload=load_all, dump=dump_all)
     
    import relative_demand_grid
    relative_demand_grid.main(reload=load_all, dump= dump_all, dump_csv = dump_all)
     
    import zone_driver
    zone_driver.main(reload=load_all, dump= dump_all)
    print "job done!"
Example #4
0
def main():
  parser = optparse.OptionParser(usage='usage: %prog [options] [test_names]')
  parser.add_option('-e', '--environment_type', help='Environment type',
                    default=None)
  parser.add_option('-n', '--name', help='Environment name', default=None)
  parser.add_option('-p', '--environment_params',
                    help='Environment parameters if creating an environment '
                    'for the test', default=None)
  parser.add_option('-t', '--test_params', help='Test parameters',
                    default=None)
  utils.add_options(parser)
  global _options
  _options, _ = parser.parse_args()
  del sys.argv[1:]

  utils.main()
def setUp():
  """Sets up VtGate for integration tests in Java client"""

  create_table = '''create table vtgate_test (
  id bigint auto_increment,
  name varchar(64),
  age SMALLINT,
  percent DECIMAL(5,2),
  keyspace_id bigint(20) unsigned NOT NULL,
  primary key (id)
  ) Engine=InnoDB'''
  vtgatev2_test.create_tables.append(create_table)
  utils.main(vtgatev2_test)
  # this is read in Java test to set up connection params
  sys.stdout.write(json.dumps({
      "port": vtgatev2_test.vtgate_port,
      "keyspace_name": vtgatev2_test.KEYSPACE_NAME,
      "shard_kid_map": vtgatev2_test.shard_kid_map,
  }))
  sys.stdout.flush()
Example #6
0
    def get(self, anno_id):
        # they can request a certain format by ending with .gobe whatever.
        self.response.headers['Content-type'] = 'text/plain';

        if anno_id == "":
            a = Annotation.all().order("-date").get()
        elif anno_id != "all":
            a = Annotation.all().filter('anno_id = ', anno_id).get()
        if a is None: a = Annotation()
        content = a.content

        if a.format and a.format != "gobe":
            content = [x.strip() for x in content.split("\n")]
            content = utils.main(content, a.format, force_tabs=True)

        self.response.out.write(content or "")
#!/usr/bin/env python
#
# Copyright 2014, Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can
# be found in the LICENSE file.

import utils
import resharding

from vtdb import keyrange_constants

# this test is the same as resharding_bytes.py, but it uses vtworker to
# do the clone.
if __name__ == '__main__':
  resharding.keyspace_id_type = keyrange_constants.KIT_BYTES
  resharding.use_clone_worker = True
  utils.main(resharding)
Example #8
0
    doctest.testmod()

    from optparse import OptionParser

    parser = OptionParser(__doc__)
    supported_fmts = ("bed", "gff", "blast")
    parser.add_option("--format", dest="format", default="bed",
            choices=supported_fmts,
            help="choose one of %s" % (supported_fmts,) + " [default: %default]")
    parser.add_option("--feature-types", dest="feature_types",
                      default=None, help=
            "include list of feature types (separated by comma); types not "
            "in the list are excluded (e.g. --feature-types CDS,exon,gene ")
    parser.add_option("--qadjust", dest="qadjust", type='int', default=0, 
                      help="adjust local query blast coordinates to chromosomal coords")
    parser.add_option("--sadjust", dest="sadjust", type='int', default=0, 
                      help="adjust local subject blast coordinates to chromosomal coords")
    parser.add_option("--title", dest="title", help="optional descriptor for"
                      " this dataset. if specified, the data will be uploaded to"
                      " try-gobe.appspot.com and a url will be printed where you"
                      " can view your data")

    opts, args = parser.parse_args()
    if len(args) != 1:
        sys.exit(parser.print_help())

    bed_file = args[0]

    print utils.main(bed_file, opts.format, opts.feature_types, title=opts.title, qadjust=opts.qadjust, sadjust=opts.sadjust)

Example #9
0
def main():
    utils.main(parse_func, exec_func)
Example #10
0
def main():
    utils.main(InTheEnd.InTheEndGame)    
Example #11
0
      except urllib2.HTTPError as e:
        self.assertEqual(e.code, 307)
      # Verify that the command logged something and its available at /status.
      status = urllib2.urlopen(worker_base_url + '/status').read()
      self.assertIn(
          "Ping command was called with message: 'pong'", status,
          'Command did not log output to /status')

      # Reset the job.
      urllib2.urlopen(worker_base_url + '/reset').read()
      status_after_reset = urllib2.urlopen(worker_base_url + '/status').read()
      self.assertIn(
          'This worker is idle.', status_after_reset,
          '/status does not indicate that the reset was successful')


def add_test_options(parser):
  parser.add_option(
      '--num_insert_rows', type='int', default=100,
      help='The number of rows, per shard, that we should insert before '
      'resharding for this test.')
  parser.add_option(
      '--num_insert_rows_before_reparent_test', type='int', default=3000,
      help='The number of rows, per shard, that we should insert before '
      'running TestReparentDuringWorkerCopy (supersedes --num_insert_rows in '
      'that test). There must be enough rows such that SplitClone takes '
      'several seconds to run while we run a planned reparent.')

if __name__ == '__main__':
  utils.main(test_options=add_test_options)
Example #12
0
#!/usr/bin/env python
#
# Copyright 2013, Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can
# be found in the LICENSE file.

"""Re-runs merge_sharding.py with a varbinary keyspace_id."""

from vtdb import keyrange_constants

import base_sharding
import merge_sharding
import utils


if __name__ == '__main__':
  base_sharding.keyspace_id_type = keyrange_constants.KIT_BYTES
  utils.main(merge_sharding)
Example #13
0
def Completo():
    funciones.LimpiaDirectorio(ruta)
    speedtest.main()
    utils.main()
    ProcesosComunes()
#!/usr/bin/env python
#
# Copyright 2014, Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can
# be found in the LICENSE file.

import utils
import initial_sharding

from vtdb import keyrange_constants

# this test is the same as initial_sharding_bytes.py, but it uses vtworker to
# do the clone.
if __name__ == '__main__':
    initial_sharding.use_clone_worker = True
    initial_sharding.keyspace_id_type = keyrange_constants.KIT_BYTES
    utils.main(initial_sharding)
Example #15
0
        logging.info('Fetching main vtctl page: %s', self.vtctl_addr)
        self.driver.get(self.vtctl_addr)

        self._check_shard_overview('test_keyspace', '-80', {
            'master': 1,
            'replica': 1,
            'rdonly': 0
        })
        self._check_shard_overview('test_keyspace', '80-', {
            'master': 1,
            'replica': 1,
            'rdonly': 0
        })
        self._check_shard_overview('test_keyspace2', '0', {
            'master': 1,
            'replica': 1,
            'rdonly': 1
        })


def add_test_options(parser):
    parser.add_option('--no-xvfb',
                      action='store_false',
                      dest='xvfb',
                      default=True,
                      help='Use local DISPLAY instead of headless Xvfb mode.')


if __name__ == '__main__':
    utils.main(test_options=add_test_options)
Example #16
0
        cursor.execute(query, {'id': 1, 'message': 'hello world 1'})
        cursor.execute(query, {'id': 4, 'message': 'hello world 4'})
        cursor.commit()

        (it, fields) = vtgate_conn.message_stream(keyspace, name)
        self.assertEqual(fields, [('id', query_pb2.INT64),
                                  ('message', query_pb2.VARCHAR)])

        # We should get both messages.
        result = {}
        for _ in xrange(2):
            row = it.next()
            result[row[0]] = row[1]
        self.assertEqual(result, {1: 'hello world 1', 4: 'hello world 4'})

        # After ack, we should get only one message.
        count = vtgate_conn.message_ack(name, [4])
        self.assertEqual(count, 1)
        result = {}
        for _ in xrange(2):
            row = it.next()
            result[row[0]] = row[1]
        self.assertEqual(result, {1: 'hello world 1'})
        # Only one should be acked.
        count = vtgate_conn.message_ack(name, [1, 4])
        self.assertEqual(count, 1)


if __name__ == '__main__':
    utils.main()
#!/usr/bin/env python
#
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Re-runs resharding.py with a varbinary keyspace_id."""

from vtdb import keyrange_constants

import base_sharding
import resharding
import utils

# this test is just re-running an entire resharding.py with a
# varbinary keyspace_id
if __name__ == '__main__':
    base_sharding.keyspace_id_type = keyrange_constants.KIT_BYTES
    utils.main(resharding)
        keyspace = 'test_keyspace'
        source_shard_list = "0"
        dest_shard_list = "-80,80-"
        _protocol, endpoint = utils.vtctld.rpc_endpoint()
        utils.run(
            environment.binary_argstr('automation_client') +
            ' --server localhost:' + str(automation_server_port) +
            ' --task HorizontalReshardingTask' + ' --param keyspace=' +
            keyspace + ' --param source_shard_list=' + source_shard_list +
            ' --param dest_shard_list=' + dest_shard_list +
            ' --param source_shard_rdonly_list=' +
            worker.shard_rdonly1.tablet_alias +
            ' --param dest_shard_rdonly_list=' +
            worker.shard_0_rdonly1.tablet_alias + ',' +
            worker.shard_1_rdonly1.tablet_alias + ' --param vtctld_endpoint=' +
            endpoint + ' --param vtworker_endpoint=localhost:' +
            str(worker_rpc_port))

        self.assert_shard_data_equal(0, worker.shard_master,
                                     worker.shard_0_tablets.replica)
        self.assert_shard_data_equal(1, worker.shard_master,
                                     worker.shard_1_tablets.replica)

        utils.kill_sub_process(automation_server_proc, soft=True)
        utils.kill_sub_process(worker_proc, soft=True)


if __name__ == '__main__':
    utils.main(test_options=worker.add_test_options)
Example #19
0
#!/usr/bin/env python
#
# Copyright 2017 Google Inc.
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Re-runs update_stream.py with RBR."""

import update_stream
import utils

if __name__ == '__main__':
  update_stream.use_rbr = True
  utils.main(update_stream)
Example #20
0
#!/usr/bin/env python

# Copyright 2017 Google Inc.
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


"""Re-runs backup.py with use_mysqlctld=True."""

import backup
import utils

if __name__ == '__main__':
  backup.use_mysqlctld = True
  utils.main(backup)
Example #21
0
#!/usr/bin/env python
#
# Copyright 2017 Google Inc.
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Re-runs resharding.py with RBR on."""

import base_sharding
import vertical_split
import utils

if __name__ == '__main__':
  base_sharding.use_rbr = True
  utils.main(vertical_split)
Example #22
0
def main():
  print "Note: This is a slow test, has a couple of sleeps in it to simulate proper state changes"
  utils.main()
Example #23
0
# course: Kickstart Coding
# date: 11/19/19
# name: Victor Sanchez
# description: Templating for a static-site generator

from utils import main
import sys
from slugify import slugify

if len(sys.argv) < 3 and len(sys.argv) > 1:
    command = sys.argv[1]

    if command == "build":
        print("Build was specified")
        main()
    elif command == "new":
        print("New page was specified")
        new_name = slugify(input("New file name: "))
        print('New file created:', (new_name + '.html'))
        new_filename = ('content/' + new_name + '.html')
        new_content = open('templates/new_content_temp.html').read()
        open(new_filename, "w+").write(new_content)

else:
    print("\nPlease specify 'build' or 'new'\n"
          'Usage:\n'
          '   Rebuild site: python manage.py build\n'
          '   Create new page: python manage.py new')
Example #24
0
def Diagnostico():
    funciones.LimpiaDirectorio(ruta)
    utils.main()
    ProcesosComunes()
Example #25
0
            self.game_data[item.name] = item

    def remove_possession(self, name):
        item = self.game_data[name]
        item.count -= 1
        if not item.count:
            del self.game_data[name]
            self.possessions.remove(item)

    def make_opt_epilog(self):
        return ""

    def add_quiz_answer(self, q, a):
        self.game_data[q] = a
        self.quiz_answers.append([q, a])

    def first_situation(self):
        return OpeningCredits(self)

    def _jump_to_situation(self):
        if self.jump_to.endswith(".csv"):
            self.jump_to = "MainSituation_%s" % self.jump_to.split(".csv")[0]

        sit = globals()[self.jump_to](self)
        utils._log("JUMPING TO SITUATION: %s (%s)" % (self.jump_to, sit.__class__.__name__))
        return sit


if __name__ == "__main__":
    utils.main(InTheEndGame)
Example #26
0
#!/usr/bin/env python
#
# Copyright 2013, Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can
# be found in the LICENSE file.

import initial_sharding
import utils

from vtdb import keyrange_constants

# this test is just re-running an entire initial_sharding.py with a
# varbinary keyspace_id
if __name__ == '__main__':
  initial_sharding.keyspace_id_type = keyrange_constants.KIT_BYTES
  utils.main(initial_sharding)
    return model


def generate_main(args):
    """
    generates text from trained model specified in args.
    main method for generate subcommand.
    """
    # load learning model for config and weights
    model = load_model(args.checkpoint_path)
    # build inference model and transfer weights
    inference_model = build_inference_model(model)
    inference_model.set_weights(model.get_weights())
    logger.info("model loaded: %s.", args.checkpoint_path)

    # create seed if not specified
    if args.seed is None:
        with open(args.text_path) as f:
            text = f.read()
        seed = generate_seed(text)
        logger.info("seed sequence generated from %s.", args.text_path)
    else:
        seed = args.seed

    return generate_text(inference_model, seed, args.length, args.top_n)


if __name__ == "__main__":
    logger = get_logger(__name__, console=True)
    main("Keras", train_main, generate_main)
        #
        # We must run an explicit healthcheck or we can see one of the two states:
        # - NOT_SERVING, DisableQueryService=false, tablet type 'spare'
        #   (immediately after SplitDiff returned)
        # - SERVING, DisableQueryService=false, tablet type 'rdonly'
        #   (during healthcheck before post-action callback is called)
        utils.run_vtctl(["RunHealthCheck", worker.shard_rdonly1.tablet_alias], auto_log=True)

        # source shard: query service must be disabled after MigrateServedTypes.
        utils.check_tablet_query_service(self, worker.shard_rdonly1, serving=False, tablet_control_disabled=True)
        utils.check_tablet_query_service(self, worker.shard_replica, serving=False, tablet_control_disabled=True)
        utils.check_tablet_query_service(self, worker.shard_master, serving=False, tablet_control_disabled=True)

        # dest shard -80: query service must be disabled after MigrateServedTypes.
        # Run explicit healthcheck because 'rdonly' tablet may still be 'spare'.
        utils.run_vtctl(["RunHealthCheck", worker.shard_0_rdonly1.tablet_alias], auto_log=True)
        utils.check_tablet_query_service(self, worker.shard_0_rdonly1, serving=True, tablet_control_disabled=False)
        utils.check_tablet_query_service(self, worker.shard_0_replica, serving=True, tablet_control_disabled=False)
        utils.check_tablet_query_service(self, worker.shard_0_master, serving=True, tablet_control_disabled=False)

        # dest shard 80-: query service must be disabled after MigrateServedTypes.
        # Run explicit healthcheck because 'rdonly' tablet is still 'spare'.
        utils.run_vtctl(["RunHealthCheck", worker.shard_1_rdonly1.tablet_alias], auto_log=True)
        utils.check_tablet_query_service(self, worker.shard_1_rdonly1, serving=True, tablet_control_disabled=False)
        utils.check_tablet_query_service(self, worker.shard_1_replica, serving=True, tablet_control_disabled=False)
        utils.check_tablet_query_service(self, worker.shard_1_master, serving=True, tablet_control_disabled=False)


if __name__ == "__main__":
    utils.main(test_options=worker.add_test_options)
#!/usr/bin/env python
#
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Re-runs vtgatev2_test.py with a l2vtgate process."""

import utils
import vtgatev2_test

# This test is just re-running an entire vtgatev2_test.py with a
# l2vtgate process in the middle.
if __name__ == '__main__':
  vtgatev2_test.use_l2vtgate = True
  utils.main(vtgatev2_test)
Example #30
0
    with self.assertRaises(dbexceptions.OperationalError):
      vtgate_conn = get_connection(user="******", password="******")

  def test_incorrect_credentials(self):
    with self.assertRaises(dbexceptions.OperationalError):
      vtgate_conn = get_connection(user=self.user, password="******")

  def test_challenge_is_used(self):
    vtgate_conn = get_connection(user=self.user, password=self.password)
    challenge = ""
    proof =  "%s %s" %(self.user, hmac.HMAC(self.password,
                                            challenge).hexdigest())
    self.assertRaises(gorpc.AppError, vtgate_conn.client.call,
                      'AuthenticatorCRAMMD5.Authenticate', {"Proof": proof})

  def test_only_few_requests_are_allowed(self):
    vtgate_conn = get_connection(user=self.user,
                                  password=self.password)
    for i in range(4):
      try:
        vtgate_conn.client.call('AuthenticatorCRAMMD5.GetNewChallenge',
                                 "")
      except gorpc.GoRpcError:
        break
    else:
      self.fail("Too many requests were allowed (%s)." % (i + 1))


if __name__ == '__main__':
  utils.main()
Example #31
0
import argparse

from utils import execute, main, get_abspath

parser = argparse.ArgumentParser(description='Restore MongoDBs')

parser.add_argument('-u', '--url',
                    type=str,
                    required=False,
                    default='mongodb://127.0.0.1:27017/',
                    help='Mongo DB URL for Backup')
parser.add_argument('-i', '--input_dir',
                    type=str,
                    required=True,
                    help='Input directory for the Restore.')
parser.add_argument('-d', '--db',
                    type=str,
                    required=False,
                    default='test_results_collection',
                    help='database name after the restore.')


def restore(args):
    input_dir = get_abspath(args.input_dir)
    cmd = ['mongorestore', '%s' % input_dir]
    execute(cmd, args)


if __name__ == '__main__':
    main(restore, parser)