Пример #1
0
 def __init__(self, name, flag_values):
     super(AddFirewall, self).__init__(name, flag_values)
     flags.DEFINE_string('description',
                         '',
                         'An optional Firewall description.',
                         flag_values=flag_values)
     flags.DEFINE_string(
         'network',
         'default',
         'Specifies which network this firewall applies to.',
         flag_values=flag_values)
     flags.DEFINE_list(
         'allowed',
         None, '[Required] Specifies a list of allowed ports for this '
         'firewall. Each entry must be a combination of the '
         'protocol and the port or port range in the following '
         'form: \'<protocol>:<port>-<port>\' or '
         '\'<protocol>:<port>\'. To specify multiple ports, '
         'protocols, or ranges, provide them as comma'
         '-separated entries. For example: '
         '\'--allowed=tcp:ssh,udp:5000-6000,tcp:80,icmp\'.',
         flag_values=flag_values)
     flags.DEFINE_list(
         'allowed_ip_sources', [],
         'Specifies a list of IP addresses that are allowed '
         'to talk to instances within the network, through the '
         '<protocols>:<ports> described by the \'--allowed\' '
         'flag. If no IP or tag sources are listed, all sources '
         'will be allowed.',
         flag_values=flag_values)
     flags.DEFINE_list(
         'allowed_tag_sources', [],
         'Specifies a list of instance tags that are allowed to '
         'talk to instances within the network, through the '
         '<protocols>:<ports> described by the \'--allowed\' '
         'flag. If specifying multiple tags, provide them as '
         'comma-separated entries. For example, '
         '\'--allowed_tag_sources=www,database,frontend\'. '
         'If no tag or ip sources are listed, all sources will '
         'be allowed.',
         flag_values=flag_values)
     flags.DEFINE_list(
         'target_tags', [], 'Specifies a set of tagged instances that this '
         'firewall applies to. To specify multiple tags, '
         'provide them as comma-separated entries. If no tags '
         'are listed, this firewall applies to all instances in '
         'the network.',
         flag_values=flag_values)
Пример #2
0
 def __init__(self, name, flag_values):
     super(AddRoute, self).__init__(name, flag_values)
     flags.DEFINE_string('description',
                         None,
                         'An optional route description.',
                         flag_values=flag_values)
     flags.DEFINE_string(
         'network',
         'default',
         'Specifies which network to apply the route to. By default, this is '
         'the \'default\' network.',
         flag_values=flag_values)
     flags.DEFINE_list(
         'tags', [],
         'Specifies a comma-separated set of tagged instances to which the '
         'route will apply. If no tags are specified, this route applies to '
         'all instances within the specified network.',
         flag_values=flag_values)
     flags.DEFINE_integer(
         'priority',
         1000,
         'Specifies the priority of this route relative to other routes with '
         'the same specificity. The lower the number, the higher the '
         'priority. The default priority is 1000.',
         lower_bound=0,
         upper_bound=2**32 - 1,
         flag_values=flag_values)
     flags.DEFINE_string(
         'next_hop_instance',
         None,
         'Specifies the name of an instance that should handle matching '
         'packets. You must provide exactly one hop, specified by one of '
         '\'--next_hop_instance\', \'--next_hop_ip\', or '
         '\'--next_hop_gateway\'. To specify \'--next_hop_instance\', '
         'provide the full URL to the instance. e.g. '
         '\'https://www.googleapis.com/compute/<api-version>/projects/'
         '<project-id>/zones/<zone-name>/instances/<instance-name>\'.',
         flag_values=flag_values)
     flags.DEFINE_string(
         'next_hop_ip',
         None, 'Specifies the IP address of an instance that should handle '
         'matching packets. You must provide exactly one hop, specified by '
         'one of \'--next_hop_instance\', \'--next_hop_ip\', or '
         '\'--next_hop_gateway\'. To specify an IP address of an instance, '
         'the IP must already exist and have IP forwarding enabled.',
         flag_values=flag_values)
     flags.DEFINE_string(
         'next_hop_gateway',
         None,
         'Specifies the gateway that should handle matching packets. You '
         'must provide exactly one hop, specified by one of '
         '\'--next_hop_instance\', \'--next_hop_ip\', or '
         '\'--next_hop_gateway\'. Currently, you can only specify the '
         'Internet gateway: '
         '\'/projects/<project-id>/global/gateways/default-internet\'.',
         flag_values=flag_values)
Пример #3
0
 def testListAsDefaultArgument_CommaSeparatedList(self):
     gflags.DEFINE_list('allow_users', ['alice', 'bob'],
                        'Users with access.',
                        flag_values=self.fv)
     expected_output = (' <flag>\n'
                        '   <file>tool</file>\n'
                        '   <name>allow_users</name>\n'
                        '   <meaning>Users with access.</meaning>\n'
                        '   <default>alice,bob</default>\n'
                        '   <current>[\'alice\', \'bob\']</current>\n'
                        '   <type>comma separated list of strings</type>\n'
                        '   <list_separator>\',\'</list_separator>\n'
                        ' </flag>\n')
     self._CheckFlagHelpInXML('allow_users', 'tool', expected_output)
Пример #4
0
def main(argv):
  """Implement a simple demo for computing error CDFs."""
  # Input/output flags.
  gflags.DEFINE_string('input_file', None, 'Full path to wing HDF5 log file.')
  gflags.MarkFlagAsRequired('input_file')
  gflags.DEFINE_string('output_file', None, 'Full path to output MAT file.')
  gflags.MarkFlagAsRequired('output_file')

  # Segment processing flags.
  gflags.DEFINE_integer('increment', 100,
                        'Integer number of messages between segments.')
  gflags.DEFINE_integer('seg_length', 1000,
                        'Integer number of messages in each segment.')

  # Evaluate segments over a specific time interval.
  gflags.DEFINE_float('start_time', -float('inf'),
                      'Start time to evaluate segment errors.')
  gflags.DEFINE_float('end_time', float('inf'),
                      'End time to evaluate segment errors.')

  # Override default parameters.
  gflags.DEFINE_list('params', [],
                     'A comma-separated list of param=value tokens, where '
                     'each param describes the dot path to a parameter in '
                     'EstimatorParams.')
  gflags.RegisterValidator('params',
                           lambda l: all(len(s.split('=')) == 2 for s in l),
                           message='Invalid key=value parameter syntax.')

  # Scenarios to process.
  gflags.DEFINE_bool('scenario_pure_inertial', False,
                     'Process pure inertial scenario.')
  gflags.DEFINE_bool('scenario_gps_dropout', False,
                     'Process GPS dropout scenario.')

  # Common faults to introduce.
  gflags.DEFINE_bool('fault_weather', False,
                     'Fault weather subsystems to avoid an assert when '
                     'reprocessing historical data.')
  gflags.DEFINE_bool('fault_glas', False, 'Fault GLAS subsystems.')

  # Specify flight for special handling.
  gflags.DEFINE_string('flight', None,
                       'Fix known issues associated with the given flight.')

  try:
    argv = gflags.FLAGS(argv)
  except gflags.FlagsError, e:
    print '{}\nUsage: {} ARGS\n{}'.format(e, sys.argv[0], gflags.FLAGS)
    sys.exit(1)
Пример #5
0
 def __init__(self, name, flag_values):
     super(AddFirewall, self).__init__(name, flag_values)
     flags.DEFINE_string('description',
                         '',
                         'Firewall description',
                         flag_values=flag_values)
     flags.DEFINE_string('network',
                         'default',
                         'Which network to apply the firewall to.',
                         flag_values=flag_values)
     flags.DEFINE_list(
         'allowed',
         None, 'The set of allowed ports for this firewall. A list of '
         'specifications of the form '
         '"(<protocol>)?(\':\'<port>(\'-\'<port>)?)?" for allowing'
         ' packets through the firewall. Examples: '
         '"tcp:ssh", "udp:5000-6000", "tcp:80", or "icmp".',
         flag_values=flag_values)
     flags.DEFINE_list(
         'allowed_ip_sources', [],
         'The set of addresses allowed to talk to the '
         'protocols:ports listed in allowed (comma separated). '
         'If no ip or tag sources are listed, all sources '
         'will be allowed.',
         flag_values=flag_values)
     flags.DEFINE_list(
         'allowed_tag_sources', [],
         'The set of tagged instances allowed to talk to the '
         'protocols:ports listed in allowed (comma separated). '
         'If no tag or ip sources are listed, all sources will '
         'be allowed.',
         flag_values=flag_values)
     flags.DEFINE_list(
         'target_tags', [],
         'The set of tagged instances to apply the firewall to '
         '(comma separated).',
         flag_values=flag_values)
 def __init__(self, name, flag_values):
     super(GetTargetPoolHealth, self).__init__(name, flag_values)
     flags.DEFINE_list(
         'instances', [],
         'Specifies the list of instance resources in a target '
         'pool to query for health status. Each entry must be '
         'specified by the instance name (e.g., '
         '\'--instances=<instance>\') or a relatively or fully '
         'qualified path to the instance instance (e.g., '
         '\'--instances=<zone>/instances/<instance>\'). To specify'
         ' multiple instances, provide them as comma-separated '
         'entries. If empty, gcutil will query the status of '
         'each instance in the pool by doing an API call for '
         'each instance.',
         flag_values=flag_values)
Пример #7
0
 def testFlagHelpInXML_CommaSeparatedList(self):
     gflags.DEFINE_list('files',
                        'a.cc,a.h,archive/old.zip',
                        'Files to process.',
                        flag_values=self.fv)
     expected_output = (
         ' <flag>\n'
         '   <file>tool</file>\n'
         '   <name>files</name>\n'
         '   <meaning>Files to process.</meaning>\n'
         '   <default>a.cc,a.h,archive/old.zip</default>\n'
         '   <current>[\'a.cc\', \'a.h\', \'archive/old.zip\']</current>\n'
         '   <type>comma separated list of strings</type>\n'
         '   <list_separator>\',\'</list_separator>\n'
         ' </flag>\n')
     self._CheckFlagHelpInXML('files', 'tool', expected_output)
Пример #8
0
    def __init__(self, name, flag_values):
        super(AddNetwork, self).__init__(name, flag_values)

        flags.DEFINE_string('description',
                            '',
                            'Network description.',
                            flag_values=flag_values)
        flags.DEFINE_string('range',
                            '10.0.0.0/8',
                            'IPv4 address range of this network.',
                            flag_values=flag_values)
        flags.DEFINE_string('gateway',
                            '10.0.0.1',
                            'IPv4 address of the gateway within the network.',
                            flag_values=flag_values)
        flags.DEFINE_list('reserve', [],
                          'IPv4 addresses on the network which should not be '
                          'automatically assigned (comma separated).',
                          flag_values=flag_values)
    def __init__(self, name, flag_values):
        super(RemoveTargetPoolInstance, self).__init__(name, flag_values)
        flags.DEFINE_string(
            'instance',
            None, '[Deprecated]. Please use --instances to remove one or '
            'more instances from the target pool.',
            flag_values=flag_values)

        flags.DEFINE_list(
            'instances', [],
            '[Required] Specifies a list of instances to be removed '
            'this target pool. Each entry must be specified by the '
            'instance name (e.g., \'--instances=<instance>\') or '
            'a relatively or fully qualified path '
            '(e.g., \'--instances=<zone>/instances/<instance>\'). To '
            'specify multiple instances, provide them as '
            'comma-separated entries. All instances in one target '
            'pool must belong to the same region as the target '
            'pool. Instances do not need to exist at the time it '
            'is added to the target pool and can be created '
            'afterwards.',
            flag_values=flag_values)
Пример #10
0
              '[email protected] (Andy Perelson)')

import gflags as flags
import __builtin__
from closure_linter import checkerbase
from closure_linter import closurizednamespacesinfo
from closure_linter import ecmametadatapass
from closure_linter import errors
from closure_linter import javascriptlintrules
from closure_linter import javascriptstatetracker
from closure_linter.common import errorprinter
from closure_linter.common import lintrunner

flags.DEFINE_list(
    'limited_doc_files', ['dummy.js', 'externs.js'],
    'List of files with relaxed documentation checks. Will not '
    'report errors for missing documentation, some missing '
    'descriptions, or methods whose @return tags don\'t have a '
    'matching return statement.')
flags.DEFINE_list(
    'closurized_namespaces', '', 'Namespace prefixes, used for testing of'
    'goog.provide/require')
flags.DEFINE_list(
    'ignored_extra_namespaces', '',
    'Fully qualified namespaces that should be not be reported '
    'as extra by the linter.')


class JavaScriptStyleChecker(checkerbase.CheckerBase):
    """Checker that applies JavaScriptLintRules."""
    def __init__(self, error_handler):
        """Initialize an JavaScriptStyleChecker object.
Пример #11
0
CLEANUP = 'cleanup'
TEARDOWN = 'teardown'

FLAGS = gflags.FLAGS
gflags.DEFINE_bool(
    PER_SECOND_GRAPHS, False, 'Indicator for using per second data collection.'
    'To enable set True.')
gflags.DEFINE_integer(
    SYSBENCH_RUN_SECONDS, 480,
    'The duration, in seconds, of each run phase with varying'
    'thread count.')
gflags.DEFINE_integer(
    SYSBENCH_WARMUP_SECONDS, 0,
    'The duration, in seconds, of the warmup run in which '
    'results are discarded.')
gflags.DEFINE_list(THREAD_COUNT_LIST, [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],
                   'The number of test threads on the client side.')
gflags.DEFINE_integer(
    SYSBENCH_REPORT_INTERVAL, 1,
    'The interval, in seconds, we ask sysbench to report '
    'results.')
gflags.DEFINE_string(
    RUN_URI, None, 'Run identifier, if provided, only run phase '
    'will be completed.')
gflags.DEFINE_string(
    RUN_STAGE, None, 'List of phases to be executed. For example:'
    '"--run_uri=provision,prepare". Available phases:'
    'prepare, provision, run, cleanup, teardown.')
gflags.DEFINE_string(GCE_BOOT_DISK_SIZE, '1000',
                     'The boot disk size in GB for GCP VMs..')
gflags.DEFINE_string(GCE_BOOT_DISK_TYPE, 'pd-ssd',
                     'The boot disk type for GCP VMs.')
Пример #12
0
# Regex to represent common mistake inverting author name and email as
# @author User Name (user@company)
INVERTED_AUTHOR_SPEC = re.compile(r'(?P<leading_whitespace>\s*)'
                                  r'(?P<name>[^(]+)'
                                  r'(?P<whitespace_after_name>\s+)'
                                  r'\('
                                  r'(?P<email>[^\s]+@[^)\s]+)'
                                  r'\)'
                                  r'(?P<trailing_characters>.*)')

FLAGS = flags.FLAGS
flags.DEFINE_boolean('disable_indentation_fixing', False,
                     'Whether to disable automatic fixing of indentation.')
flags.DEFINE_list('fix_error_codes', [], 'A list of specific error codes to '
                  'fix. Defaults to all supported error codes when empty. '
                  'See errors.py for a list of error codes.')


class ErrorFixer(errorhandler.ErrorHandler):
  """Object that fixes simple style errors."""

  def __init__(self, external_file=None):
    """Initialize the error fixer.

    Args:
      external_file: If included, all output will be directed to this file
          instead of overwriting the files the errors are found in.
    """
    errorhandler.ErrorHandler.__init__(self)
Пример #13
0
import gflags


# Checkpoints
gflags.DEFINE_integer('checkpoints_to_keep', 2, 'The number of checkpoints '
                      'to keep', lower_bound=0)
gflags.DEFINE_string('checkpoints_dir', './checkpoints', 'The path where '
                     'the model checkpoints are stored')
gflags.DEFINE_list('devices', ['/cpu:0'], 'A list of devices to use')
gflags.DEFINE_bool('debug_of', False,
                   'Show rgb and optical flow of each batch in a window ')
gflags.DEFINE_string('restore_model', 'True', 'It can be the hash of the '
                     'model we want to relaod, True (string) if you '
                     'want to reload the experiment with the hash '
                     'generated by your list of params,  '
                     'or False/None if you dont want to restore the model')

# Other flags we might want to define (see also config/flow.py):
# See https://www.tensorflow.org/versions/r0.10/tutorials/monitors/
#                customizing_the_evaluation_metrics
# metrics=[],  # TODO add additional metrics
# val_metrics=['dice_loss', 'acc', 'jaccard'],
# TODO parametrize according to which metric to save the model (best val loss?)
Пример #14
0
import random

from pygaga.helpers.logger import log_init
from pygaga.helpers.dbutils import get_db_engine
from pygaga.helpers.utils import extract_json_from_jsonp
from pygaga.helpers.statsd import Statsd

from guang_crawler.taobao_api import convert_taobaoke_widget

FLAGS = gflags.FLAGS

gflags.DEFINE_enum('action', 'update', ['remove', 'update', 'vip'],
                   "action: remove/update/vip")
gflags.DEFINE_boolean('force', False, "force convert taobaoke")
gflags.DEFINE_boolean('all', False, "remove all taobaoke link")
gflags.DEFINE_list('vipshopids', [4, 5, 15, 111], "client shop ids")
gflags.DEFINE_integer('shop', 0, "remove all taobaoke link for shop")

gflags.DEFINE_integer('limit', 0, "for test: limit how much items proccess")
gflags.DEFINE_string('where', ' true ', "additional where")
gflags.DEFINE_integer('interval', 3, "convert how many days")

gflags.DEFINE_string('pid', '30146700', "default taobaoke pid")

gflags.DEFINE_boolean('dryrun', False, "is in dry run mode?")

logger = logging.getLogger('TaobaokeLogger')


def do_all(fn):
    db = get_db_engine()
 def __init__(self, name, flag_values):
     super(AddTargetPool, self).__init__(name, flag_values)
     flags.DEFINE_string('description',
                         '',
                         'An optional Target Pool description',
                         flag_values=flag_values)
     flags.DEFINE_list(
         'health_checks', [],
         'Specifies a HttpHealthCheck resource to use to '
         'determine the health of VMs in this pool. '
         'If no health check is specified, traffic will be '
         'sent to all instances in this target pool as if the '
         'instances were healthy, but the health status of this '
         'pool will appear as unhealthy as a warning that this '
         'target pool does not have a health check.',
         flag_values=flag_values)
     flags.DEFINE_list(
         'instances', [],
         '[Required] Specifies a list of instances that will '
         'receive traffic directed to this target pool. Each '
         'entry must be specified by the instance name '
         '(e.g., \'--instances=myinstance\') or a relative or '
         'fully-qualified path to the instance (e.g., '
         '\'--instances=<zone>/instances/myotherinstance\'). To '
         'specify multiple instances, provide them as '
         'comma-separated entries. All instances in one target '
         'pool must belong to the same region as the target pool. '
         'Instances do not need to exist at the time the target '
         'pool is created and can be created afterwards.',
         flag_values=flag_values)
     gcutil_flags.DEFINE_case_insensitive_enum(
         'session_affinity',
         self.DEFAULT_SESSION_AFFINITY,
         ['NONE', 'CLIENT_IP', 'CLIENT_IP_PROTO'],
         'Specifies the session affinity option for the '
         'connection. Options include:'
         '\n NONE: connections from the same client IP '
         'may go to any VM in the target pool '
         '\n CLIENT_IP: connections from the same client IP '
         'will go to the same VM in the target pool; '
         '\n CLIENT_IP_PROTO: connections from the same '
         'client IP with the same IP protocol will go to the '
         'same VM in the targetpool. ',
         flag_values=flag_values)
     flags.DEFINE_float(
         'failover_ratio',
         None, 'If set, --backup_pool must also be set to point to an '
         'existing target pool in the same region. They together '
         'define the fallback behavior of the target pool '
         '(primary pool) to be created by this command: if the '
         'ratio of the healthy VMs in the primary pool is at '
         'or below this number, traffic arriving at the '
         'load-balanced IP will be directed to the backup pool. '
         'If not set, the traaffic will be directed the VMs in '
         'this pool in the "force" mode, where traffic will be '
         'spread to the healthy VMs with the best effort, or '
         'to all VMs when no VM is healthy.',
         flag_values=flag_values)
     flags.DEFINE_string(
         'backup_pool',
         None, 'Together with --failover_ratio, this flag defines '
         'the fallback behavior of the target pool '
         '(primary pool) to be created by this command: if the '
         'ratio of the healthy VMs in the primary pool is at '
         'or below --failover_ratio, traffic arriving at the '
         'load-balanced IP will be directed to the backup '
         'pool. ',
         flag_values=flag_values)
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import gflags  # sudo pip install python-gflags
import sys
import scipy as sp  # sudo pip install spicy
from scipy import stats
import math

#gflags.DEFINE_string('cris', None, 'un parametro para testear', short_name='c')
gflags.DEFINE_string('size', None, 'The model size', short_name='s')
gflags.DEFINE_list('device_name', None, 'Broken device name',
                   short_name='d')  # pass devices name separated with ,
#gflags.DEFINE_string('size', 149, 'The model size', short_name='s')
gflags.MarkFlagAsRequired('size')
gflags.MarkFlagAsRequired('device_name')

FLAGS = gflags.FLAGS

try:
    argv = FLAGS(sys.argv)  # parse flags
except gflags.FlagsError, e:
    print '%s\nUsage: %s ARGS\n%s' % (e, sys.argv[0], FLAGS)
    sys.exit(1)

#print "anduvo", FLAGS.size

df_Command = pd.DataFrame()
df_Devices = pd.DataFrame()
df_Task = pd.DataFrame()
for prob in range(10, 100, 10):
flags.DEFINE_string(
    'source_properties_file', None, '[bazel ONLY] the path to '
    'a source.properties file for this system image')
flags.DEFINE_string('adb', None, 'The path to ADB')
flags.DEFINE_string('emulator_x86', None, '[bazel ONLY] the path to '
                    'emulator_x86')
flags.DEFINE_string('emulator_arm', None, '[bazel ONLY] the path to '
                    'emulator_arm')
flags.DEFINE_string('adb_static', None, 'OBSOLETE: the path to adb.static')
flags.DEFINE_string('adb_turbo', None, 'The path to turbo adb')
flags.DEFINE_string('emulator_x86_static', None, 'Deprecated. NO-OP.')
flags.DEFINE_string('emulator_arm_static', None, 'Deprecated. NO-OP.')
flags.DEFINE_string('empty_snapshot_fs', None, '[bazel ONLY] the path to '
                    'a snapshot fs image')
flags.DEFINE_string('mksdcard', None, '[bazel ONLY] the path to ' 'mksdcard')
flags.DEFINE_list('bios_files', None, '[bazel ONLY] a list of bios files for '
                  'the emulator.')
flags.DEFINE_list(
    'broadcast_message', None, '[START ONLY] a list of strings '
    'in the format key=value. These will be broadcast as extras '
    'when the emulator is fully booted and after all apks have '
    'been installed. They will be broadcast under the action '
    'ACTION_MOBILE_NINJAS_START')
flags.DEFINE_string(
    'emulator_metadata_path', None, '[bazel ONLY] the path to '
    'a metadata protobuffer to start the emulator with.')
flags.DEFINE_string(
    'export_launch_metadata_path', None, '[START ONLY] writes '
    'emulator metadata after launch to this path')
flags.DEFINE_string(
    'emulator_tmp_dir', None, 'Temporary directory where the '
    'emulator sockets/system_images/ramdisk etc are placed when'
Пример #18
0
from closure_linter import checkerbase
from closure_linter import ecmametadatapass
from closure_linter import error_check
from closure_linter import errorrules
from closure_linter import errors
from closure_linter import indentation
from closure_linter import javascripttokenizer
from closure_linter import javascripttokens
from closure_linter import statetracker
from closure_linter import tokenutil
from closure_linter.common import error
from closure_linter.common import position


FLAGS = flags.FLAGS
flags.DEFINE_list('custom_jsdoc_tags', '', 'Extra jsdoc tags to allow')
# TODO(user): When flipping this to True, remove logic from unit tests
# that overrides this flag.
flags.DEFINE_boolean('dot_on_next_line', False, 'Require dots to be'
                     'placed on the next line for wrapped expressions')

flags.DEFINE_boolean('check_trailing_comma', False, 'Check trailing commas'
                     ' (ES3, not needed from ES5 onwards)')

# TODO(robbyw): Check for extra parens on return statements
# TODO(robbyw): Check for 0px in strings
# TODO(robbyw): Ensure inline jsDoc is in {}
# TODO(robbyw): Check for valid JS types in parameter docs

# Shorthand
Context = ecmametadatapass.EcmaContext
Пример #19
0
    'typically where you\'d find ./corp and ./prod')
flags.DEFINE_string('definitions_directory', './def',
                    'Directory where the definitions can be found.')
flags.DEFINE_string('policy_file', None, 'Individual policy file to generate.')
flags.DEFINE_string('output_directory', './',
                    'Directory to output the rendered acls.')
flags.DEFINE_boolean('optimize',
                     False,
                     'Turn on optimization.',
                     short_name='o')
flags.DEFINE_boolean(
    'recursive', True,
    'Descend recursively from the base directory rendering acls')
flags.DEFINE_boolean('debug', False, 'Debug messages')
flags.DEFINE_boolean('verbose', False, 'Verbose messages')
flags.DEFINE_list('ignore_directories', 'DEPRECATED, def',
                  "Don't descend into directories that look like this string")
flags.DEFINE_integer('max_renderers', 10,
                     'Max number of rendering processes to use.')
flags.DEFINE_boolean(
    'shade_check', False,
    'Raise an error when a term is completely shaded by a prior term.')
flags.DEFINE_integer(
    'exp_info', 2,
    'Print a info message when a term is set to expire in that many weeks.')


class Error(Exception):
    """Base Error class."""


class P4WriteFileError(Error):
Пример #20
0
return status in the case of command-line applications and a 200 OK response in
the case of the App Engine and Django samples.
"""
import gflags
import httplib2
import logging
import os
import signal
import subprocess
import sys
import time

FLAGS = gflags.FLAGS

gflags.DEFINE_list(
    'samples_to_skip', ['latitude'],
    'A comma separated list of project directory names to be skipped.')

gflags.DEFINE_enum('logging_level', 'INFO',
                   ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],
                   'Set the level of logging detail.')

gflags.DEFINE_string('app_engine_dir', '../google_appengine/',
                     'Directory where Google App Engine is installed.')

gflags.DEFINE_string('sample_root', 'samples/oauth2',
                     'The root directory for all the samples.')


def main(argv):
    try:
Пример #21
0
import logging
import os
import re
import string
import sys

import gflags
import makani
from makani.lib.log_synchronizer import auto_upload
from makani.lib.python.batch_sim import gcloud_util

gflags.DEFINE_string('config_path',
                     os.path.join(makani.HOME,
                                  'lib/log_synchronizer/logsync_config.json'),
                     'The configuration file on the cloud or local.')
gflags.DEFINE_list('collections', None,
                   'Collections to synchronize (default is all).')
gflags.DEFINE_list('systems', None,
                   'Systems to synchronize (default is all).')

gflags.DEFINE_boolean('debug', False, 'Produces debugging output.')

FLAGS = gflags.FLAGS


class SynchronizerError(RuntimeError):
  """Error raised to signal failures during synchronizing the logs."""


class Synchronizer(object):
  """The log synchronizer that automatically checks and uploads new logs."""
Пример #22
0
from makani.analysis.aero import load_database
from makani.control import system_types
from makani.lib.python import flag_types
from makani.sim.physics import physics
from matplotlib import pyplot
import numpy as np

FLAGS = gflags.FLAGS

flag_types.DEFINE_linspace('alphas_deg', '-10.0, 10.0, 20',
                           'Linspace range of angle-of-attack values [deg].')
flag_types.DEFINE_linspace('betas_deg', '-15.0, 15.0, 20',
                           'Linspace range of sideslip angles [deg].')
gflags.DEFINE_boolean('plot_sim', False,
                      'Whether to display the sim aero model.')
gflags.DEFINE_list('flaps_deg', [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                   'Flap deflections [deg].')
gflags.RegisterValidator('flaps_deg',
                         lambda x: len(x) == system_types.kNumFlaps,
                         'Wrong number of flaps in input.')
gflags.DEFINE_float('reynolds_number', 1e6,
                    'Reynolds number for the simulator.')
gflags.DEFINE_float('p_hat', 0.0, 'Normalized roll rate.')
gflags.DEFINE_float('q_hat', 0.0, 'Normalized pitch rate.')
gflags.DEFINE_float('r_hat', 0.0, 'Normalized yaw rate.')
gflags.DEFINE_float('thrust_coeff', 0.0, 'Total thrust coefficient.')


def _SwigVec3ToArray(v):
    """Converts a Swig Vec3 data structure to an array."""
    return np.array([v.x, v.y, v.z])
Пример #23
0
    # pylint: disable-msg=C6204
    import multiprocessing
except ImportError:
    multiprocessing = None

FLAGS = flags.FLAGS
flags.DEFINE_boolean('unix_mode', False,
                     'Whether to emit warnings in standard unix format.')
flags.DEFINE_boolean('beep', True, 'Whether to beep when errors are found.')
flags.DEFINE_boolean('time', False, 'Whether to emit timing statistics.')
flags.DEFINE_boolean('check_html', False,
                     'Whether to check javascript in html files.')
flags.DEFINE_boolean('summary', False,
                     'Whether to show an error count summary.')
flags.DEFINE_list(
    'additional_extensions', None, 'List of additional file '
    'extensions (not js) that should be treated as '
    'JavaScript files.')
flags.DEFINE_boolean(
    'multiprocess',
    platform.system() is 'Linux' and bool(multiprocessing),
    'Whether to attempt parallelized linting using the '
    'multiprocessing module.  Enabled by default on Linux '
    'if the multiprocessing module is present (Python 2.6+). '
    'Otherwise disabled by default. '
    'Disabling may make debugging easier.')

GJSLINT_ONLY_FLAGS = [
    '--unix_mode', '--beep', '--nobeep', '--time', '--check_html', '--summary'
]

Пример #24
0
import os
import sys

import gflags
import imageio
import numpy

from PIL import Image
from PIL.ImageDraw import Draw

gflags.DEFINE_string('inp', None, 'Input screenshot image')
gflags.DEFINE_string('out', None, 'Output antimated GIF')

gflags.DEFINE_integer('h', 0, 'Window height')
gflags.DEFINE_integer('maxspeed', 200, 'Max speed on scroll px/frame')
gflags.DEFINE_list('stops', [], 'List of stops for scrolling')
gflags.DEFINE_integer('zoom', 0, 'Number of steps on initial zoom in')
gflags.DEFINE_float('zoom_frac', .3, 'Fraction of screenshot to see on zoomout')

gflags.register_validator('inp', os.path.exists, 'Input screenshot required')
gflags.register_validator('h', lambda v: v > 0, 'Window height required')

F = gflags.FLAGS


def add_frame(frames, frame, duration):
    frames.append((prettify(frame), duration))


def prettify(frame):
    off = 5
Пример #25
0
try:
    import cStringIO
except ImportError:
    import io as cStringIO  # Python 3 compatibility
import inspect
import re
import sys
import types

import gflags

from . import usb_exceptions

gflags.DEFINE_integer('timeout_ms', 10000, 'Timeout in milliseconds.')
gflags.DEFINE_list('port_path', [], 'USB port path integers (eg 1,2 or 2,1,1)')
gflags.DEFINE_string('serial',
                     None,
                     'Device serial to look for (host:port or USB serial)',
                     short_name='s')

gflags.DEFINE_bool(
    'output_port_path', False,
    'Affects the devices command only, outputs the port_path '
    'alongside the serial if true.')

FLAGS = gflags.FLAGS

_BLACKLIST = {
    'Connect',
    'Close',
Пример #26
0
# 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.
"""Linter error rules class for Closure Linter."""

__author__ = '[email protected] (Robert Walker)'

import gflags as flags
from closure_linter import errors

FLAGS = flags.FLAGS
flags.DEFINE_boolean('jsdoc', True,
                     'Whether to report errors for missing JsDoc.')
flags.DEFINE_list(
    'disable', None, 'Disable specific error. Usage Ex.: gjslint --disable 1,'
    '0011 foo.js.')
""" PATCH for backwards compatibility """
flags.DEFINE_list(
    'ignore_errors', [],
    'Disable specific error. Usage Ex.: gjslint --ignore_errors 1,'
    '0011 foo.js.')

flags.DEFINE_integer('max_line_length',
                     80, 'Maximum line length allowed '
                     'without warning.',
                     lower_bound=1)

disabled_error_nums = None

Пример #27
0
In the case of collecting artifacts from a host via GRR you may need approval
for the host in question.
"""

import webbrowser
import re
import sys
import gflags

from dftimewolf.lib import collectors
from dftimewolf.lib import processors
from dftimewolf.lib import timesketch_utils
from dftimewolf.lib import utils as timewolf_utils

FLAGS = gflags.FLAGS
gflags.DEFINE_list(u'hosts', [],
                   u'One or more hostnames to collect artifacts from with GRR')
gflags.DEFINE_string(u'hunt_id', None,
                     u'Existing hunt to download current result set from')
gflags.DEFINE_list(u'paths', [],
                   u'One or more paths to files to process on the filesystem')
gflags.DEFINE_string(u'reason', None, u'Reason for requesting _client access')
gflags.DEFINE_string(u'grr_server_url', u'http://localhost:8000',
                     u'GRR server to use')
gflags.DEFINE_string(u'timesketch_server_url', u'http://localhost:5000',
                     u'Timesketch server to use')
gflags.DEFINE_string(u'artifacts', None,
                     u'Comma separated list of GRR artifacts to fetch')
gflags.DEFINE_boolean(u'use_tsk', False, u'Use TSK for artifact collection')
gflags.DEFINE_string(u'timezone', None, u'Timezone to use for Plaso processing')
gflags.DEFINE_list(
    u'approvers', None,
Пример #28
0
__author__ = ('[email protected] (Robert Walker)',
              '[email protected] (Andy Perelson)',
              '[email protected] (Jacob Richman)')

import gflags as flags
from closure_linter import ecmalintrules
from closure_linter import errors
from closure_linter import javascripttokenizer
from closure_linter import javascripttokens
from closure_linter import tokenutil
from closure_linter.common import error
from closure_linter.common import position

FLAGS = flags.FLAGS
flags.DEFINE_list('closurized_namespaces', '',
                  'Namespace prefixes, used for testing of'
                  'goog.provide/require')
flags.DEFINE_list('ignored_extra_namespaces', '',
                  'Fully qualified namespaces that should be not be reported '
                  'as extra by the linter.')

# Shorthand
Error = error.Error
Position = position.Position
Type = javascripttokens.JavaScriptTokenType


class JavaScriptLintRules(ecmalintrules.EcmaScriptLintRules):
  """JavaScript lint rules that catch JavaScript specific style errors."""

  def HandleMissingParameterDoc(self, token, param_name):
Пример #29
0
    def __init__(self, name, flag_values):
        super(AddInstance, self).__init__(name, flag_values)

        flags.DEFINE_string('description',
                            '',
                            'Instance description',
                            flag_values=flag_values)
        flags.DEFINE_string(
            'image',
            None, 'Image name. To get a list of images built by Google, '
            'run \'gcutil listimages --project=projects/google\'. '
            'To get a list of images you have built, run \'gcutil '
            'listimages\'.',
            flag_values=flag_values)
        flags.DEFINE_string(
            'machine_type',
            None, 'Machine type name. To get a list of available machine '
            'types, run \'gcutil listmachinetypes\'.',
            flag_values=flag_values)
        flags.DEFINE_string('network',
                            'default',
                            'The network to which to attach the instance.',
                            flag_values=flag_values)
        flags.DEFINE_string(
            'internal_ip_address',
            '', 'The internal (within the specified network) IP '
            'address for the instance; if not set the instance '
            'will be assigned an appropriate address.',
            flag_values=flag_values)
        flags.DEFINE_string(
            'external_ip_address',
            self.EPHEMERAL_ACCESS_CONFIG_NAT_IP,
            'The external NAT IP of the new instance. The default '
            'value "ephemeral" indicates the service should choose '
            'an available ephemeral IP. The value "none" (or an '
            'empty string) indicates no external IP will be '
            'assigned to the new instance. If an explicit IP is '
            'given, that IP must be reserved by the project and '
            'not yet assigned to another instance.',
            flag_values=flag_values)
        flags.DEFINE_multistring(
            'disk', [], 'The name of a disk to be attached to the '
            'instance. The name may be followed by a '
            'comma-separated list of name=value pairs '
            'specifying options. Legal option names are '
            '\'deviceName\', to specify the disk\'s device '
            'name, and \'mode\', to indicate whether the disk '
            'should be attached READ_WRITE (the default) or '
            'READ_ONLY',
            flag_values=flag_values)
        flags.DEFINE_boolean(
            'use_compute_key',
            False, 'Whether or not to include the default '
            'Google Compute Engine ssh key as one of the '
            'authorized ssh keys for the created instance. This '
            'has the side effect of disabling project-wide ssh '
            'key management for the instance.',
            flag_values=flag_values)
        flags.DEFINE_boolean(
            'add_compute_key_to_project',
            None, 'Whether or not to add the default Google Compute '
            'Engine ssh key as one of the authorized ssh keys '
            'for the project. If the default key has already '
            'been added to the project, then this will have no '
            'effect. The default behavior is to add the key to '
            'the project if no instance-specific keys are '
            'defined.',
            flag_values=flag_values)
        flags.DEFINE_list(
            'authorized_ssh_keys', [],
            'Fix the list of user/key-file pairs to the specified '
            'entries, disabling project-wide key management for this '
            'instance. These are specified as a comma separated list '
            'of colon separated entries: '
            'user1:keyfile1,user2:keyfile2,...',
            flag_values=flag_values)
        flags.DEFINE_string('zone',
                            None,
                            'The zone for this instance.',
                            flag_values=flag_values)
        flags.DEFINE_string(
            'service_account',
            'default', 'The service account whose credentials are to be made'
            ' available for this instance.',
            flag_values=flag_values)
        flags.DEFINE_list(
            'service_account_scopes', [],
            'The scopes of credentials of the above service'
            ' account that are to be made available for this'
            ' instance (comma separated).  There are also a set of '
            'scope aliases supported: %s' %
            ', '.join(sorted(scopes.SCOPE_ALIASES.keys())),
            flag_values=flag_values)
        flags.DEFINE_boolean(
            'wait_until_running',
            False, 'Whether the program should wait until the instance is'
            ' in running state.',
            flag_values=flag_values)
        flags.DEFINE_list('tags', [],
                          'A set of tags applied to this instance. Used for '
                          'filtering and to configure network firewall rules '
                          '(comma separated).',
                          flag_values=flag_values)

        self._metadata_flags_processor = metadata.MetadataFlagsProcessor(
            flag_values)
Пример #30
0
import gflags
import os
import logging
import sys
import traceback

from pygaga.helpers.logger import log_init
from pygaga.helpers.dbutils import get_db_engine

logger = logging.getLogger('CrawlLogger')

FLAGS = gflags.FLAGS

gflags.DEFINE_boolean('all', True, "Is crawl all shops")
gflags.DEFINE_boolean('dryrun', False, "Is dry run")
gflags.DEFINE_list('shopids', [], "crawl shopids")

def crawl_main():
    if FLAGS.shopids:
        cond = "id in (%s)" % ",".join(FLAGS.shopids)
    elif FLAGS.all:
        cond = "1"
    else:
        logger.error("Args error, run with --help to get more info.")
        sys.exit(0)
    db = get_db_engine()

    sql = "update shop set crawl_status=1 where %s" % cond
    if FLAGS.dryrun:
        logger.debug(sql)
    else: