Beispiel #1
0
# feature classes have a 'transition' method, which, given a rule and its
# antecedents, computes a feature cost and possibly a new state.

from ngram import NgramEnumerator
from logprob import elog, elog10
from rule import get_num_edges
from rule import isvar
import logger
import sys
import gflags
FLAGS = gflags.FLAGS
from mymonitor import human, memory

gflags.DEFINE_boolean(
    'use_python_lm',
    False,
    'Use the python lm module in place of the swig srilm wrapper.')

class Feature(object):
    def __init__(self):
        """features should do only trivial jobs in __init__. more serious
        jobs should be postponed to 'initialize' method"""
        # a feature is stateless if it can be computed from the rule alone
        self.stateless = True

        # if a feature is not stateless, this index is set by add_feature so
        # that feature knows the index of its state in an item's state list
        self.i = None

        # feature name is used for printing information, weight matching, etc
        self.name = self.__class__.__name__
Beispiel #2
0
import gflags as flags

from . import errorrecord
from . import runner
from .common import erroraccumulator
from .common import simplefileflags as fileflags

# Attempt import of multiprocessing (should be available in Python 2.6 and up).
try:
    # pylint: disable=g-import-not-at-top
    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 '
Beispiel #3
0
    def height(self, level=0):
        if self.is_terminal():
            return 1
        return max([sub.height() for sub in self.subs]) + 1


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

## attached code does empty node removal ##

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

if __name__ == "__main__":

    flags.DEFINE_integer("max_len", 400, "maximum sentence length")
    flags.DEFINE_boolean("pp", False, "pretty print")
    flags.DEFINE_boolean("height", False, "output the height of each tree")
    #    flags.DEFINE_boolean("wordtags", False, "output word/tag sequence")
    #    flags.DEFINE_boolean("words", False, "output word sequence")
    flags.DEFINE_boolean("clean", False,
                         "clean up functional tags and empty nodes")

    argv = FLAGS(sys.argv)

    for i, line in enumerate(sys.stdin):
        t = Tree.parse(line.strip(), trunc=FLAGS.clean)
        if len(t) <= FLAGS.max_len:
            if FLAGS.pp:
                t.pp()
            elif FLAGS.height:
                print("%d\t%d" % (len(t), t.height()))
Beispiel #4
0
from modules.canbus.proto import chassis_pb2
from modules.localization.proto import localization_pb2
from modules.map.relative_map.proto import navigation_pb2
from path_decider import PathDecider
from speed_decider import SpeedDecider
from trajectory_generator import TrajectoryGenerator
from provider_mobileye import MobileyeProvider
from provider_chassis import ChassisProvider
from provider_localization import LocalizationProvider
from provider_routing import RoutingProvider
from obstacle_decider import ObstacleDecider
from ad_vehicle import ADVehicle

gflags.DEFINE_integer('max_cruise_speed', 20,
                      'max speed for cruising in meter per second')
gflags.DEFINE_boolean('enable_follow', False, 'enable follow function.')
gflags.DEFINE_boolean('enable_nudge', True, 'enable nudge function.')
gflags.DEFINE_boolean('enable_change_lane', False,
                      'enable change lane function.')
gflags.DEFINE_boolean('enable_routing_aid', True,
                      'enable planning leveraging routing information.')
gflags.DEFINE_string('navigation_planning_node_name', 'navigation_planning',
                     'node name for navigation planning.')
gflags.DEFINE_string('navigation_planning_topic', '/apollo/planning',
                     'navigation planning publish topic.')

planning_pub = None
log_file = None
path_decider = None
speed_decider = None
traj_generator = None
Beispiel #5
0
from pygaga.helpers.ratelimit import waitlimit
from pygaga.helpers.dbutils import get_db_engine

from guang_crawler.taobao_api import get_report, get_top

gflags.DEFINE_string(
    'sessionid', "6101a2091623b5bc1ec813739d8d158539f719c08ef9a96814424732",
    "taobao session id")
gflags.DEFINE_string('start', "",
                     "get report start from yyyymmdd, default today")
gflags.DEFINE_string('end', "", "get report end to yyyymmdd, default today")
gflags.DEFINE_integer('interval', 0,
                      "if not 0, ignore start params, start=end-interval")
gflags.DEFINE_integer('limit', 30, "how many api calls per minutes")

gflags.DEFINE_boolean('dryrun', False, "not commit to database")

gflags.DEFINE_boolean('csv', False, "output to csv")
gflags.DEFINE_string('csv_encoding', 'gb18030', "csv encoding, gbk or utf8")
gflags.DEFINE_string('csv_split', ';', "csv splitter")
gflags.DEFINE_string('csv_quote', '"', "csv quote")
gflags.DEFINE_string('csv_filename', 'output.csv', "csv filename")

logger = logging.getLogger('TaobaoLogger')

FLAGS = gflags.FLAGS


def dates():
    end = datetime.now()
    interval = 1
   solutions being generated using a cheapest addition heuristic.
   Optionally one can randomly forbid a set of random connections between nodes
   (forbidden arcs).
"""

import random

from google.apputils import app
import gflags
from ortools.constraint_solver import pywrapcp

FLAGS = gflags.FLAGS

gflags.DEFINE_integer('tsp_size', 4,
                      'Size of Traveling Salesman Problem instance.')
gflags.DEFINE_boolean('tsp_use_random_matrix', True, 'Use random cost matrix.')
gflags.DEFINE_integer('tsp_random_forbidden_connections', 0,
                      'Number of random forbidden connections.')
gflags.DEFINE_integer('tsp_random_seed', 0, 'Random seed.')
gflags.DEFINE_boolean('light_propagation', False, 'Use light propagation')

# Cost/distance functions.


def Distance(i, j):
    """Sample function."""
    # Put your distance code here.
    return i + j


class RandomMatrix(object):
Beispiel #7
0
                     'Encoding used in runtime string processing')
gflags.DEFINE_string('entities_path', '', 'Path to the entities file')
gflags.DEFINE_string(
    'user_agent',
    'Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.11 (KHTML, like Gecko) '
    'Chrome/23.0.1271.97 Safari/537.11', 'User Agent used to crawl pages')
gflags.DEFINE_float('min_absolute_score', 1e-10,
                    'Minimal absolute score for a candidate to be accepted')
gflags.DEFINE_float(
    'min_relative_score', 0.2,
    'Minimal score relative to that of the top candidate for a '
    'candidate to be accepted')
gflags.DEFINE_integer('max_candidates', 10,
                      'Maximal number of candidates to pick for each page')
gflags.DEFINE_boolean(
    'match_partial_image_url', True,
    'If set to true, only match the filename part of the image url')
gflags.DEFINE_boolean(
    'must_match_image_url', False,
    'If set to true, only pick candidates if the page being analyzed '
    'matches the provided image url')
gflags.DEFINE_boolean('display_surtext', False,
                      'If set to true, surrounding text will be displayed')
gflags.DEFINE_integer(
    'header_length', 1000,
    'Presumed length of the header section that includes title and meta tags')
gflags.DEFINE_integer(
    'header_equivalent_distance', 200,
    'If an entity is found in the header section, use this equivalent distance'
)
gflags.DEFINE_integer('min_distance', 200,
Beispiel #8
0
#      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.

"""Helper script used by app_unittest.sh"""



import sys

import gflags as flags
from google.apputils import app

FLAGS = flags.FLAGS
flags.DEFINE_boolean("raise_exception", False, "throw MyException from main")

class MyException(Exception):
  pass

def main(args):
  if FLAGS.raise_exception:
    raise MyException


if __name__ == '__main__':
  app.run()
Beispiel #9
0
#!/usr/bin/env python3

from heapq import heapify, heappush, heappop
import os

import gflags
FLAGS = gflags.FLAGS
import logger
from rule import Rule, isvar, nocat
from logprob import elog
from percent_counter import PercentCounter
import decoding_flags

gflags.DEFINE_boolean('merge_rules_with_same_f', False,
                      'Share rules with the same f to save memory.')


class RuleBin(object):
    def __init__(self, K):
        self.K = K  # size limit
        self.rules = []
        if FLAGS.merge_rules_with_same_f:
            self.f = None
        self.sorted = False

    def add(self, rule):
        # experiments show this has little effect
        if FLAGS.merge_rules_with_same_f:
            if self.f:
                rule.f = self.f  # all rules in bin share f
            else:
Beispiel #10
0
"""Flags for calling BigQuery."""

import os

import gflags as flags

FLAGS = flags.FLAGS
flags.DEFINE_string(
    'apilog', None,
    'Turn on logging of all server requests and responses. If no string is '
    'provided, log to stdout; if a string is provided, instead log to that '
    'file.')
flags.DEFINE_string('api', 'https://www.googleapis.com',
                    'API endpoint to talk to.')
flags.DEFINE_string('api_version', 'v2', 'API version to use.')
flags.DEFINE_boolean('debug_mode', False,
                     'Show tracebacks on Python exceptions.')
flags.DEFINE_string(
    'trace', None, 'A tracing token of the form "token:<token>" '
    'to include in api requests.')

flags.DEFINE_string(
    'bigqueryrc', os.path.join(os.path.expanduser('~'), '.bigqueryrc'),
    'Path to configuration file. The configuration file specifies '
    'new defaults for any flags, and can be overrridden by specifying the '
    'flag on the command line. If the --bigqueryrc flag is not specified, the '
    'BIGQUERYRC environment variable is used. If that is not specified, the '
    'path "~/.bigqueryrc" is used.')
flags.DEFINE_string(
    'credential_file',
    os.path.join(os.path.expanduser('~'), '.bigquery.v2.token'),
    'Filename used for storing the BigQuery OAuth token.')
Beispiel #11
0
import sys
import datetime

import gflags
FLAGS = gflags.FLAGS

gflags.DEFINE_boolean('time_stamp', False, 'Print time stamps.')

level = 1
file = sys.stderr


def writeln(s=""):
    if FLAGS.time_stamp:
        file.write('[%s] %s\n' % (datetime.datetime.utcnow(), s))
    else:
        file.write("%s\n" % s)
    file.flush()


def write(s):
    file.write(s)
    file.flush()
Beispiel #12
0
FLAGS = gflags.FLAGS

BAILOUT_FILE = os.path.join(os.path.dirname(__file__), os.pardir, 'BAILOUT')

gflags.DEFINE_string('alice_solver', None, 'Path to alice solver binary.')
gflags.MarkFlagAsRequired('alice_solver')

gflags.DEFINE_integer('initial_arguments', 3,
                      'Number of arguments initially given to cardinal.')

gflags.DEFINE_string(
    'detail_log_dir', None,
    'Problem details for post-mortem are logged to this directory.')
gflags.MarkFlagAsRequired('detail_log_dir')

gflags.DEFINE_boolean('keep_going', False, 'Keep going even on expiration')

gflags.DEFINE_integer('time_limit_sec', 300, 'Time limit in seconds')


class Alice(object):
    def __init__(self):
        self.proc = subprocess.Popen([FLAGS.alice_solver],
                                     stdin=subprocess.PIPE,
                                     stdout=subprocess.PIPE)
        self._WaitReady()

    def _WaitReady(self):
        logging.info(
            'Alice is booting. This can take a while and consumes a lot of RAM.'
        )
Beispiel #13
0
            dct[k] = max(v, dct[k]) if k in dct else v
          steps, val = zip(*sorted(dct.iteritems()))
          plt.plot(steps, val, label="Log%d:%s-%d" % (log_ind, attr, index))
    
  plt.xlabel("No. of training iteration")
  plt.ylabel(FLAGS.ylabel)
  if FLAGS.legend:
    plt.legend()
  plt.show()


if __name__ == '__main__':
  
  gflags.DEFINE_string("path", None, "Path to log file")
  gflags.DEFINE_string("index", "1", "csv list of corpus indices. 0 for train, 1 for eval set 1 etc.")
  gflags.DEFINE_boolean("pred_acc", True, "Prediction accuracy")
  gflags.DEFINE_boolean("parse_acc", False, "Parsing accuracy")
  gflags.DEFINE_boolean("total_cost", False, "Total cost, valid only if index == 0")
  gflags.DEFINE_boolean("xent_cost", False, "Cross entropy cost, valid only if index == 0")
  gflags.DEFINE_boolean("l2_cost", False, "L2 regularization cost, valid only if index == 0")
  gflags.DEFINE_boolean("action_cost", False, "Action cost, valid only if index == 0")
  gflags.DEFINE_boolean("legend", False, "Show legend in plot")
  gflags.DEFINE_boolean("subplot", False, "Separate plots for each log")
  gflags.DEFINE_string("ylabel", "", "Label for y-axis of plot")
  gflags.DEFINE_integer("iters", 10000, "Iters to limit plot to")

  FLAGS(sys.argv)
  assert FLAGS.path is not None, "Must provide a log path"
  ShowPlots(FLAGS.subplot)
  
Beispiel #14
0
import gflags
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."""
Beispiel #15
0

_GLOBS = find_devices()

if _GLOBS:
    _DEFAULT_PORT = _GLOBS[0]
else:
    _DEFAULT_PORT = '/dev/ttyUSB0'

FLAGS = gflags.FLAGS

gflags.DEFINE_integer('kegboard_speed', 115200,
                      'Baud rate of device at --kegboard_device')

gflags.DEFINE_boolean('verbose',
                      os.environ.get('VERBOSE') is not None,
                      'Generate extra logging information.',
                      allow_override=True)


def get_kegboard(glob_paths=None):
    """Immediately returns a Kegboard if available, None otherwise.

  Args:
    glob_paths: Paths to test for a valid kegboard.
  """
    return wait_for_kegboard(timeout=0, glob_paths=glob_paths)


def wait_for_kegboard(interval=0.1, timeout=None, glob_paths=None):
    if not glob_paths:
        glob_paths = DEFAULT_GLOB_PATHS
Beispiel #16
0
import time

import gflags

from collections import OrderedDict

from apiclient.discovery import build
from oauth2client.client import OAuth2WebServerFlow
from oauth2client.file import Storage
from oauth2client.tools import run


FLAGS = gflags.FLAGS

# Flags related to operations on task lists.
gflags.DEFINE_boolean(
  'add', False, 'Add operation', short_name='a')
gflags.DEFINE_boolean(
  'clear', False, 'Clear operation', short_name='c')
gflags.DEFINE_boolean(
  'delete', False, 'Delete operation', short_name='d')
gflags.DEFINE_boolean(
  'edit', False, 'Edit operation', short_name='e')
gflags.DEFINE_boolean(
  'list', False, 'List operation', short_name='l')
gflags.DEFINE_boolean(
  'move', False, 'Move operation', short_name='m')
gflags.DEFINE_boolean(
  'new', False, 'New operation', short_name='n')
gflags.DEFINE_boolean(
  'remove', False, 'Remove operation', short_name='r')
gflags.DEFINE_boolean(
            for index, sentence in enumerate(ptb):
                if index == FLAGS.print_latex:
                    break
                print(to_latex(ptb[sentence]))
                print(to_latex(report[sentence]))
                print()
        print(str(corpus_stats(report, ptb)) + '\t' + str(corpus_average_depth(report)))
        set_correct, set_total = corpus_stats_labeled(report, ptb_labeled)
        correct.update(set_correct)
        total.update(set_total)

    for key in sorted(total):
        print(key + '\t' + str(correct[key] * 1. / total[key]))


if __name__ == '__main__':
    gflags.DEFINE_string("main_report_path_template", "./checkpoints/*.report", "A template (with wildcards input as \*) for the paths to the main reports.")
    gflags.DEFINE_string("main_data_path", "./snli_1.0/snli_1.0_dev.jsonl", "A template (with wildcards input as \*) for the paths to the main reports.")
    gflags.DEFINE_string("ptb_report_path_template", "_", "A template (with wildcards input as \*) for the paths to the PTB reports, or '_' if not available.")
    gflags.DEFINE_string("ptb_data_path", "_", "The path to the PTB data in SNLI format, or '_' if not available.")
    gflags.DEFINE_boolean("compute_self_f1", True, "Compute self F1 over all reports matching main_report_path_template.")
    gflags.DEFINE_boolean("use_random_parses", False, "Replace all report trees with randomly generated trees. Report path template flags are not used when this is set.")
    gflags.DEFINE_boolean("use_balanced_parses", False, "Replace all report trees with roughly-balanced binary trees. Report path template flags are not used when this is set.")
    gflags.DEFINE_boolean("first_two", False, "Show 'first two' and 'last two' metrics.")
    gflags.DEFINE_boolean("neg_pair", False, "Show 'neg_pair' metric.")
    gflags.DEFINE_integer("print_latex", 0, "Print this many trees in LaTeX format for each report.")

    FLAGS(sys.argv)

    run()
Beispiel #18
0
import socket
import sys
import webbrowser

import gflags
from six.moves import input

from oauth2client import client
from oauth2client import util
from oauth2client.tools import ClientRedirectHandler
from oauth2client.tools import ClientRedirectServer

FLAGS = gflags.FLAGS

gflags.DEFINE_boolean('auth_local_webserver', True,
                      ('Run a local web server to handle redirects during '
                       'OAuth authorization.'))

gflags.DEFINE_string('auth_host_name', 'localhost',
                     ('Host name to use when running a local web server to '
                      'handle redirects during OAuth authorization.'))

gflags.DEFINE_multi_int('auth_host_port', [8080, 8090],
                        ('Port to use when running a local web server to '
                         'handle redirects during OAuth authorization.'))


@util.positional(2)
def run(flow, storage, http=None):
    """Core code for a command-line application.
"""GFlags for lstm."""
import gflags

gflags.DEFINE_integer("lstm_input_dim", 64, "Input feature dimensions.")
gflags.DEFINE_integer("lstm_hidden_dim", 64, "LSTM hidden dimensions.")
gflags.DEFINE_integer("lstm_num_layers", 2, "Number of lstm layers.")
gflags.DEFINE_boolean("lstm_bias", True, "Extra bias values for the lstm.")
gflags.DEFINE_float("lstm_dropout", 0.0, "LSTM dropout.")
gflags.DEFINE_boolean("lstm_bidirectional", False, "Bidirectional LSTM.")
Beispiel #20
0
from lib import windows_advfirewall

import gflags as flags
import logging

FLAGS = flags.FLAGS
flags.DEFINE_string(
    'base_directory', '.', 'The base directory to look for acls; '
    '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,
Beispiel #21
0
with information from the APIs Console <https://code.google.com/apis/console>.
""" % os.path.join(os.path.dirname(__file__), CLIENT_SECRETS)

# Set up a Flow object to be used if we need to authenticate.
FLOW = flow_from_clientsecrets(CLIENT_SECRETS,
                               scope='https://www.googleapis.com/auth/drive',
                               message=MISSING_CLIENT_SECRETS_MESSAGE)

gflags.DEFINE_enum('logging_level', 'ERROR',
                   ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],
                   'Set the level of logging detail.')
gflags.DEFINE_string('destination',
                     'downloaded/',
                     'Destination folder location',
                     short_name='d')
gflags.DEFINE_boolean('debug', False, 'Log folder contents as being fetched')
gflags.DEFINE_string('logfile', 'drive.log',
                     'Location of file to write the log')
gflags.DEFINE_string('drive_id', 'root',
                     'ID of the folder whose contents are to be fetched')


def open_logfile():
    if not re.match('^/', FLAGS.logfile):
        FLAGS.logfile = FLAGS.destination + FLAGS.logfile
    global LOG_FILE
    LOG_FILE = open(FLAGS.logfile, 'w+')


def log(str):
    LOG_FILE.write((str + '\n').encode('utf8'))
Beispiel #22
0
#!/usr/bin/env python3
import os

import gflags
FLAGS = gflags.FLAGS

from common import INF
from logprob import logsum, logprod, LOGZERO
from cube import Cube
import logger

gflags.DEFINE_boolean(
    'minimize_path_cost',
    False,
    'This fix the bug that path with cost closest to 0 is considered best.')

def escape_quote(s):
    return s.replace('"', r'\"')

class Node(object):
    def __init__(self):
        self.incoming = []
        self.nout = 0  # number of outgoing edges
        self.hg = None  # hypergraph this node belongs to
        self.best_paths_list = None

    def add_incoming(self, edge):
        self.incoming.append(edge)
        edge.head = self

    def best_paths(self):
Beispiel #23
0
import sys
logs = sys.stderr

import model
from collections import defaultdict

import gflags as flags
FLAGS = flags.FLAGS

from deptree import DepTree, DepVal

flags.DEFINE_boolean("use_gold_tags", False,
                     "simulate training with gold_tags")
flags.DEFINE_boolean(
    "limit_unk_tags", False,
    "limit the possible tags for unk words depending on its chars (only for Chinese)"
)
flags.DEFINE_boolean(
    "presuf", False,
    "prefix and suffix of the words (for both Chinese and English)")

import copy


class NewState(object):
    '''stack is a list of DepTrees.
       status=0/1/2=SH/LR/RR.
       score is forward (accumulative) cost.
       step is the number of steps.
       [i,j] span boundaries (next word is sent[j]).
       feats is features before concatenation with LEFT/RIGHT/SHIFT.
Beispiel #24
0
                      short_name='t')
gflags.DEFINE_string('batchfile',
                     None, 'A file containing a description of '
                     'packages to be downloaded.',
                     short_name='b')
gflags.DEFINE_string('nfshost',
                     None,
                     'The path to an NFS share on the host.',
                     short_name='h')
gflags.DEFINE_string('nfsguest',
                     None,
                     'The path to an NFS share on the guest.',
                     short_name='g')
gflags.DEFINE_boolean(
    'textout',
    False, 'Activate text output for analysis '
    'results. By default, the results are output to a binary '
    'protocol buffer.',
    short_name='a')
gflags.DEFINE_integer('processes',
                      1,
                      'Number of concurrent analysis processes.',
                      short_name='p')
gflags.DEFINE_boolean('snapshot',
                      True, 'Activate snapshot mode, which avoids '
                      'writing modifications to the VM image.',
                      short_name='s')
gflags.DEFINE_boolean('updatebroker',
                      False, 'Update the broker package on the '
                      'VM image before proceeding with the analysis.',
                      short_name='u')
Beispiel #25
0
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."""

  def __init__(self, config_file):
    """Initialize the synchronizer.

    Args:
Beispiel #26
0
from modules.drivers.proto import mobileye_pb2
from modules.planning.proto import planning_pb2
from modules.canbus.proto import chassis_pb2
from modules.localization.proto import localization_pb2
from path_decider import PathDecider
from speed_decider import SpeedDecider
from trajectory_generator import TrajectoryGenerator
from provider_mobileye import MobileyeProvider
from provider_chassis import ChassisProvider
from provider_localization import LocalizationProvider
from provider_routing import RoutingProvider

gflags.DEFINE_integer('max_cruise_speed', 20,
                      'max speed for cruising in meter per second')
gflags.DEFINE_boolean('enable_follow', False, 'enable follow function.')
gflags.DEFINE_boolean('enable_routing_aid', True,
                      'enable planning leveraging routing information.')
gflags.DEFINE_string('navigation_planning_node_name', 'navigation_planning',
                     'node name for navigation planning.')
gflags.DEFINE_string('navigation_planning_topic', '/apollo/planning',
                     'navigation planning publish topic.')

planning_pub = None
log_file = None
path_decider = None
speed_decider = None
traj_generator = None
mobileye_provider = None
chassis_provider = None
localization_provider = None
Beispiel #27
0
#! /usr/bin/env python
# coding: utf-8

import gflags
import logging
import traceback
import re

from pygaga.helpers.logger import log_init
from pygaga.helpers.dbutils import get_db_engine
from pygaga.helpers.urlutils import download, parse_html
from loan import Loan

logger = logging.getLogger('CrawlLogger')
FLAGS = gflags.FLAGS
gflags.DEFINE_boolean('debug_parser', False, 'is debug?')

DEFAULT_UA = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)"
REFEREE = "https://www.tzydb.com"
ID_RE = re.compile("\(([^)]*)\)")


def download_page(url, headers, max_retry_count=5):
    return download(url, headers, max_retry=max_retry_count, throw_on_banned=True)


def crawl():
    company_id = 11
    url = "https://www.tzydb.com"
    request_headers = {'User-Agent': DEFAULT_UA}
Beispiel #28
0
            offset -= native_hz
            emitted += 1              # adjust for emitting 1 output sample
          chan_buffers = tuple(c[need:] for c in chan_buffers)
          now = time.time()
          if now - last_flush >= 0.99:  # flush every second
            sys.stdout.flush()
            last_flush = now
    except KeyboardInterrupt:
      print >>sys.stderr, "interrupted"

    mon.StopDataCollection()


if __name__ == '__main__':
  # Define flags here to avoid conflicts with people who use us as a library
  flags.DEFINE_boolean("status", None, "Print power meter status")
  flags.DEFINE_integer("avg", None,
                       "Also report average over last n data points")
  flags.DEFINE_float("voltage", None, "Set output voltage (0 for off)")
  flags.DEFINE_float("current", None, "Set max output current")
  flags.DEFINE_string("usbpassthrough", None, "USB control (on, off, auto)")
  flags.DEFINE_integer("samples", None,
                       "Collect and print this many samples. "
                       "-1 means collect indefinitely.")
  flags.DEFINE_integer("hz", 5000, "Print this many samples/sec")
  flags.DEFINE_string("device", None,
                      "Path to the device in /dev/... (ex:/dev/ttyACM1)")
  flags.DEFINE_integer("serialno", None, "Look for a device with this serial number")
  flags.DEFINE_boolean("timestamp", None,
                       "Also print integer (seconds) timestamp on each line")
  flags.DEFINE_boolean("ramp", True, "Gradually increase voltage")
Beispiel #29
0
USER = os.environ['USER']
HOME_DIR = '/home/%s/trunk/src' % USER
SCRIPTS_DIR = HOME_DIR + '/scripts'
DEVSERVER_DIR = HOME_DIR + '/platform/dev'

# Paths to image signing directory and dev key.
VBOOT_REF_DIR = HOME_DIR + '/platform/vboot_reference'
IMG_SIGN_DIR = VBOOT_REF_DIR + '/scripts/image_signing'
DEVKEYS = VBOOT_REF_DIR + '/tests/devkeys'

FLAGS = gflags.FLAGS

gflags.DEFINE_string('board', None, 'Platform to build.')
gflags.DEFINE_string('base_image', None, 'Path to base image.')
gflags.DEFINE_string('firmware_updater', None, 'Path to firmware updater.')
gflags.DEFINE_boolean('start_devserver', False, 'Start devserver.')

class KillableProcess():
  """A killable process.
  """

  running_process = None

  def __init__(self, cmd, timeout=60, cwd=CWD):
    """Initialize process

    Args:
      cmd: command to run.
    """
    self.cmd = shlex.split(cmd)
    self.cmd_timeout = timeout
Beispiel #30
0
    if not gflags.FLAGS.is_parsed():
        gflags.FLAGS(sys.argv)
    cluster = util.cluster_from_json(gflags.FLAGS.cluster_config_path)
    cluster.update_metadata(False)
    CleanUp(Scenario(cluster=cluster))()


if __name__ == "__main__":
    gflags.DEFINE_string("path", None, "Test file pattern.", short_name="p")
    gflags.DEFINE_integer("num_procs", 6,
                          "Number of parallel test processes to run")
    gflags.DEFINE_string("cluster_config_path", None,
                         "Path to the cluster configuration file.")
    gflags.DEFINE_string("curie_vmdk_goldimages_dir", None,
                         "Path to the Curie worker goldimages")
    gflags.DEFINE_boolean("debug", True, "If True, enable DEBUG log messages.")

    gflags.FLAGS(sys.argv)
    curie_log.initialize(logtostderr=True, debug=gflags.FLAGS.debug)

    proto_patch_encryption_support(curie_server_state_pb2.CurieSettings)
    proto_patch_encryption_support(curie_test_pb2.CurieTestConfiguration)
    proto_patch_encryption_support(curie_types_pb2.ConnectionParams)

    cluster_cleanup()
    try:
        # Replace tags inside parentheses with an empty string, e.g.
        # 'integration/steps/test_meta.py (AHV)' becomes
        # 'integration/steps/test_meta.py'.
        path = re.sub(r'\s+\(.*\)\s*', r'', gflags.FLAGS.path)
        success = nose.run(argv=[