Esempio n. 1
0
TODO(dgreiman): Remove silly main-detection logic, and force all clients
of this module to check __name__ explicitly.  Fix all current clients
that don't check __name__.

"""

import pdb
import sys
import traceback
from google3.pyglib import build_data
from google3.pyglib import flags
from google3.pyglib import logging

FLAGS = flags.FLAGS

flags.DEFINE_boolean('run_with_pdb', 0, 'Set to true for PDB debug mode')


# Try to import pywrapbase and swig_flags.  It may fail if the
# original BUILD file did not list it as a dependency, in which case
# we can't use_cpp_logging.  This is a best-effort approach.  If
# pywrapbase can't be imported, then swig_flags will fail as it
# imports pywrapbase as well.  Set swig_flags to None in the
# ImportError case.
#
# We must do this here as we need swig_flags imported as early as
# possible so as to read the valid C++ flags before argument parsing.
try:
  # use indirect importing as per dgreiman to avoid autopar picking up
  # false dependencies
  __import__('google3.base.pywrapbase')
import sys

from google3.pyglib import flags
from google3.pyglib import logging
from google3.enterprise.legacy.production.babysitter import config_factory
from google3.enterprise.legacy.util import E

true = 1
false = 0
FLAGS = flags.FLAGS

flags.DEFINE_string("config_file", "", "The configuration file")
flags.DEFINE_string("machine", "", "The machine where the server runs")
flags.DEFINE_integer("port", None, "The port for the server", lower_bound=0)
flags.DEFINE_boolean("useinvalidconfig", false,
                     "Is it ok for the babysitter to use invalid config")
flags.DEFINE_boolean("kill_only", false, "Dont restart, just kill")
flags.DEFINE_boolean("use_python2", false, "use python2 to invoke babysitter")


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

    if not FLAGS.machine: sys.exit("Must specify a machine")
    if not FLAGS.port: sys.exit("Must specify a port")
    if not FLAGS.config_file: sys.exit("Config file must be specified")
Esempio n. 3
0
import sys
import time
from google3.base import pywrapbase
from google3.pyglib import gfile
from google3.pyglib import logging
from google3.enterprise.legacy.adminrunner import configurator
from google3.enterprise.legacy.adminrunner import config_xml_serialization
from google3.enterprise.legacy.adminrunner import entconfig

from google3.pyglib import flags

FLAGS = flags.FLAGS

flags.DEFINE_string('enthome', None, 'Enterprise home')
flags.DEFINE_string('xml_path', None, 'Path to XML configuration')
flags.DEFINE_boolean('do_export', 0, 'Export configuration')
flags.DEFINE_boolean('do_import', 0, 'Import configuration')

logging.set_googlestyle_logfile(log_dir='/export/hda3/logs')


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

    if not FLAGS.enthome:
        sys.exit('Must specify --enthome')

    if not FLAGS.xml_path:
Esempio n. 4
0
    v = start
    if v < 0.8: v = 0.8  # HVPM doesn't support lower than this
    while v < end:
        mon.setVout(v)
        v += .3
    mon.setVout(end)


def AmpsToApi(amps):
    return amps
    #/15.625 * 65535


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_integer("current", None, "Set max output current")
    flags.DEFINE_float("startcurrent", None, "Set max power-up/inital current")
    flags.DEFINE_string("usbpassthrough", None, "USB control (on, off, auto)")
    flags.DEFINE_integer("samples", None,
                         "Collect and print this many samples")
    flags.DEFINE_integer("hz", 5000, "Print this many samples/sec")
    flags.DEFINE_integer("serialno", None,
                         "Look for this Monsoon serial number")
    flags.DEFINE_boolean(
        "timestamp", None,
        "Also print integer (seconds) timestamp on each line")
    flags.DEFINE_boolean(
Esempio n. 5
0
import socket
import sys

from optparse import OptionParser
from apiclient.oauth import RequestError

try:
    from urlparse import parse_qsl
except ImportError:
    from cgi import parse_qsl


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.'))


class ClientRedirectServer(BaseHTTPServer.HTTPServer):
  """A server to handle OAuth 1.0 redirects back to localhost.

  Waits for a single request and parses the query parameters
Esempio n. 6
0
import google3.pyglib.debug

and then in your main():

google3.pyglib.debug.Init()

Then run your program with --pdb.
"""

__author__ = "[email protected] (Andrew Chatham)"

import sys

from google3.pyglib import flags

flags.DEFINE_boolean('pdb', 0, "Drop into pdb on uncaught exceptions")

old_excepthook = None


def _handler(type, value, tb):
    if not flags.FLAGS.pdb or hasattr(sys, 'ps1') or not sys.stderr.isatty():
        # we aren't in interactive mode or we don't have a tty-like
        # device, so we call the default hook
        old_excepthook(type, value, tb)
    else:
        import traceback
        import pdb
        # we are in interactive mode, print the exception...
        traceback.print_exception(type, value, tb)
        print
Esempio n. 7
0
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import json
import os
import sys
from google3.experimental.users.jeremyschanz.netCdfPlugin.plugins import netcdf_metadata_reader as reader
from google3.experimental.users.jeremyschanz.netCdfPlugin.plugins import netcdf_mysql as tracking_db
from google3.pyglib import app
from google3.pyglib import flags
from google3.pyglib import gfile

FLAGS = flags.FLAGS
flags.DEFINE_boolean(
    'walk_files', False, 'Walks through all the files specified and creates '
    'database entries, queued up to be processed.')
flags.DEFINE_boolean(
    'create_csv', False, 'Generates CSV at designated location output_root + '
    'output_file')
flags.DEFINE_string('output_root', ('/bigstore/commerce-channels-gtech-feeds'
                                    '/Axon Pilots/cloud/noaa/goes16/'),
                    'Root location of the generated CSV files.')
flags.DEFINE_string('output_file', 'abi_l2_cmip.csv',
                    'Name of CSV file being generated.')
flags.DEFINE_integer('batch_size', 50,
                     'How many files to process in a single SQL call.')
flags.DEFINE_integer('max_to_process', -1,
                     'How many files to process before exit. -1 == do all.')
flags.DEFINE_string('location_root', '/bigstore/gcp-public-data-goes-16/',
                    'Root location of the files to be processed.')
Esempio n. 8
0
# 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.
"""Regenerates readable JS and build logs."""

import os
import re
from subprocess import PIPE
from subprocess import Popen

from google3.pyglib import app
from google3.pyglib import flags

FLAGS = flags.FLAGS

flags.DEFINE_boolean("logs", True, "skips jscompiler step if false.")
flags.DEFINE_string("name_filter", ".*",
                    "only process readables matched by this regexp")
flags.DEFINE_boolean("skip_integration", False, "only build readables.")

JAVA_DIR = "third_party/java_src/j2cl/transpiler/javatests/"
READABLE_TARGET_PATTERN = JAVA_DIR + "com/google/j2cl/transpiler/readable/..."
INTEGRATION_TARGET_PATTERN = JAVA_DIR + "com/google/j2cl/transpiler/integration/..."


class CmdExecutionError(Exception):
    """Indicates that a cmd execution returned a non-zero exit code."""


def extract_pattern(pattern_string, from_value):
    """Returns the regex matched value."""
Esempio n. 9
0
_level_names = {
  FATAL: 'FATAL',
  ERROR: 'ERROR',
  WARN:  'WARN',
  INFO:  'INFO',
  DEBUG: 'DEBUG',
  }
# create the inverse of _level_names
_level_names_inverse = dict([(v,k) for (k,v) in _level_names.items()])

##############################################################################
# Global flags
##############################################################################

flags.DEFINE_integer("verbosity", 0, "Logging verbosity", short_name="v")
flags.DEFINE_boolean("logtostderr", 0, "Should only log to stderr?")
flags.DEFINE_boolean("alsologtostderr", 0, "also log to stderr?")
flags.DEFINE_string("stderrthreshold", "fatal",
                    "log messages at this level, or more severe, to stderr in "
                    "addition to the logfile.  Possible values are "
                    "'debug', 'info', 'warn', 'error', and 'fatal'.  "
                    "Obsoletes --alsologtostderr")
flags.DEFINE_boolean("threadsafe_log_fatal", 1,
                     "If 0, logfatal dies in a non-threadsafe way, but is "
                     "more useful for unittests because it raises an exception")
flags.DEFINE_string("log_dir", os.getenv('GOOGLE_LOG_DIR'),
                    "directory to write logfiles into")
flags.DEFINE_boolean("showprefixforinfo", 1, "Prepend prefix to info messages")

__all__ = ["get_verbosity", "set_verbosity", "set_logfile",
           "skip_log_prefix", "google2_log_prefix", "set_log_prefix",
Esempio n. 10
0
from google3.enterprise.legacy.production.babysitter import servertype
from google3.enterprise.legacy.util import E
from google3.enterprise.legacy.util import C
from google3.pyglib import logging
from google3.enterprise.legacy.adminrunner import adminrunner_client
from google3.enterprise.legacy.install import install_utilities
from google3.enterprise.core import core_utils

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

from google3.pyglib import flags
FLAGS = flags.FLAGS

flags.DEFINE_string("components", "",
                    "components to act on: crawl. comma separrated")
flags.DEFINE_boolean("force", 0, "force execution")
flags.DEFINE_boolean("ignore_init_state", 0, "ignore initialization state")

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


class serve_service(ent_service.ent_service):
    def __init__(self):
        ent_service.ent_service.__init__(self, "serve", 1, "15minly", 1, 3600)
        self.flags = FLAGS
        self.components = []

    # Override init_service to set some members
    def init_service(self, ent_home):
        ent_service.ent_service.init_service(self, ent_home)
Esempio n. 11
0
#
#

import commands
import os
import re
import string
import sys

from google3.pyglib import flags

FLAGS = flags.FLAGS

flags.DEFINE_string('binname', '', 'program name')
flags.DEFINE_string('extra', '', 'extra matches, separated by space')
flags.DEFINE_boolean('kill', 0, 'kill the program')
flags.DEFINE_boolean('kill_by_group', 0, 'kill all processes in process group')
flags.DEFINE_boolean('print_only', 0, 'print the program pid')
flags.DEFINE_boolean('print_by_group', 0,
                     'print pids of all processes in process group')


def IsPythonIntepreter(binname):
    """ Check to see if it is a python intepreter:
  python, python2, python2.2, etc. all are python intepreter"""
    m = re.compile("python[0-9.]*$")
    return m.match(binname) != None


def check_cmd_is_the_one(cmd, binname, id_strings):
    """given a command string, it checks to see
Esempio n. 12
0
"""

__author__ = '[email protected] (Nick Pelly)'

import sys
import urllib

from google3.pyglib import flags
from google3.pyglib import logging
from google3.enterprise.core import core_utils
from google3.enterprise.legacy.util import E
from google3.enterprise.util import localbabysitter_util

FLAGS = flags.FLAGS

flags.DEFINE_boolean("start", 0, "Start Borgmon")
flags.DEFINE_boolean("stop", 0, "Stop Borgmon")
flags.DEFINE_integer(
    "total_nodes", None, "Total number of nodes to configure for (optional). "
    "Will read from enterprise_config if ommitted.")
flags.DEFINE_string("ver", None, "Enterprise version (required). \"4.6.4\"")
flags.DEFINE_string(
    "mode", "ACTIVE",
    "Mode to configure for. One of \"ACTIVE\", \"SERVE\", \"TEST\"")
flags.DEFINE_boolean("enable_external", 0,
                     "If true, start borgmon with \"--trusted_clients all\"")

# Define Borgmon 'mode' enumerations
ACTIVE, TEST, SERVE = range(3)

# Define a map beteen install state and Borgmon 'mode'
Esempio n. 13
0
import functools
import os
import tensorflow as tf
from google.protobuf import text_format
from google3.pyglib import app
from google3.pyglib import flags
from lstm_object_detection import evaluator
from lstm_object_detection import model_builder
from lstm_object_detection.inputs import seq_dataset_builder
from lstm_object_detection.utils import config_util
from object_detection.utils import label_map_util

tf.logging.set_verbosity(tf.logging.INFO)
flags = tf.app.flags
flags.DEFINE_boolean('eval_training_data', False,
                     'If training data should be evaluated for this job.')
flags.DEFINE_string(
    'checkpoint_dir', '',
    'Directory containing checkpoints to evaluate, typically '
    'set to `train_dir` used in the training job.')
flags.DEFINE_string('eval_dir', '', 'Directory to write eval summaries to.')
flags.DEFINE_string(
    'pipeline_config_path', '',
    'Path to a pipeline_pb2.TrainEvalPipelineConfig config '
    'file. If provided, other configs are ignored')
flags.DEFINE_boolean(
    'run_once', False, 'Option to only run a single pass of '
    'evaluation. Overrides the `max_evals` parameter in the '
    'provided config.')
FLAGS = flags.FLAGS
Esempio n. 14
0
from google3.enterprise.legacy.production.babysitter import validatorlib
from google3.enterprise.legacy.production.babysitter import googleconfig

FLAGS = flags.FLAGS

flags.DEFINE_string("config_file", "", "The configuration file")
flags.DEFINE_string("param", "", "The paramter we want to update")
flags.DEFINE_string("value", "", "The repr() value of the parameter")
flags.DEFINE_string(
    "op", None,
    "Which operation we're performing: set_var, set_file_var_content, del_var, del_file_var_content"
)
flags.DEFINE_integer("force", None, "Force the update even when the new"\
                     " value is not different from the old one")
flags.DEFINE_boolean(
    "force_no_validate", False,
    "Force the update without validation - a bad idea in "
    "general but sometimes necessary")
flags.DEFINE_integer("no_extra_req", None, "Do not write subsequent "\
                     "config manager requests (good for testing")

true = 1
false = 0


# GetChangedParams takes a parameter name and value, and compares it with
# the value stored in config to see if it has changed.
# If value is a map it will return _all_ changed submaps.
# It returns a list of (name, value) pairs; tuple var names will be used
# to name submaps.
def GetChangedParams(name, value, config, force):
    results = []
from google3.enterprise.legacy.install import version_utilities
from google3.enterprise.legacy.production.babysitter import config_factory
from google3.enterprise.legacy.util import E
from google3.enterprise.legacy.util import find_master
from google3.enterprise.legacy.util import reconfigurenet_util
from google3.enterprise.legacy.util import svs_utilities
from google3.enterprise.util import borgmon_util
from google3.enterprise.util import sessionmanager_util

flags.DEFINE_string("enthome", None,
                    "Enterprise Home Directory (define this or config)")
flags.DEFINE_string("config", None,
                    "Config File Name (define this or enthome)")
flags.DEFINE_string("machines", None,
                    "Comma sepparated list of machines to take action for")
flags.DEFINE_boolean("makeactive", 0, "Changes the state to active")
flags.DEFINE_boolean("makeserve", 0, "Changes the state to serve")
flags.DEFINE_boolean("makeinactive", 0, "Changes the state to inactive")
flags.DEFINE_boolean("maketesting", 0, "Changes the state to testing")
flags.DEFINE_boolean("makeinstall", 0, "Changes the state to install")
flags.DEFINE_boolean("list", 0, "Lists the states")
flags.DEFINE_string(
    "docoreop", None,
    "Run a core op on all nodes concurrently. Core ops include "
    "activate, inactivate, info, clean, init_dns, test_gfs "
    "activate_gfs, inactivate_gfs, int_gfs, start_gfs, etc")
flags.DEFINE_boolean(
    "coreonly", 0, "Apply activate and inactivate operation to core services"
    " only. Useful for debugging core service activation and "
    "inactivation.")
flags.DEFINE_boolean(