import sys from google3.pyglib import flags from google3.pyglib import logging from google3.enterprise.legacy.production.configmgr import update_consts from google3.enterprise.legacy.production.configmgr import update_requests from google3.enterprise.legacy.production.babysitter import config_factory from google3.enterprise.legacy.production.configmgr import configmgr_request from google3.enterprise.legacy.production.babysitter import servertype 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")
# [email protected] # # This contains the code to send an epoch advance command to the specified # rtserver types # import sys from google3.pyglib import flags from google3.enterprise.legacy.production.configmgr import server_requests from google3.enterprise.legacy.production.babysitter import config_factory from google3.enterprise.legacy.production.configmgr import configmgr_request FLAGS = flags.FLAGS flags.DEFINE_string("config_file", "", "The configuration file") flags.DEFINE_integer("epoch_num", -1, "The new epoch number") flags.DEFINE_string("server_types", "", "The repr of server types to"\ "send the command to") flags.DEFINE_integer("no_extra_req", None, "Do not write subsequent "\ "config manager requests (good for testing") def execute(flag_config_file, flag_epoch_num, flag_server_types, flag_no_extra_req): if not flag_config_file: sys.exit("Must specify a config file") if flag_epoch_num < 0: sys.exit("Invalid epoch_num flag") server_types = None try:
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( "ramp", None, "Gradually increase voltage to prevent " "tripping Monsoon overvoltage") flags.DEFINE_list( "output", ["main"], "Comma-separated list of sample types " "to output (select from: main, usb, aux, voltage).") flags.DEFINE_string("delimiter", " ", "Output delimiter.")
############################################################################### import os import stat import sys from google3.enterprise.legacy.util import E from google3.pyglib import logging import glob import time ############################################################################### from google3.pyglib import flags FLAGS = flags.FLAGS flags.DEFINE_string("cleanup_dir", "", "Directory to cleanup") ############################################################################### def remove_unused_from(dirname, fileutil, grace_seconds): ''' Get a list of all files in the given directory that aren't opened and delete them. fileutil - full path of fileutil grace_seconds - Even if a file isn't currently opened we consider it being in-use if it has been accessed recently (less this many seconds ago) ''' if not dirname: logging.error("Not given a directory to cleanup")
# Copyright 2004 Google Inc. 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')
# # This contains the code to send an epoch limit delete command to # the specified rtserver types # import string import sys from google3.pyglib import flags from google3.enterprise.legacy.production.configmgr import server_requests from google3.enterprise.legacy.production.babysitter import config_factory from google3.enterprise.legacy.production.configmgr import configmgr_request FLAGS = flags.FLAGS flags.DEFINE_string("config_file", "", "The configuration file") flags.DEFINE_string("epoch_list", "", "The repr of list with epoch"\ " numbers to delete") flags.DEFINE_string("server_types", "", "The repr of server types to"\ "send the command to") flags.DEFINE_integer("no_extra_req", None, "Do not write subsequent "\ "config manager requests (good for testing") def execute(flag_config_file, flag_epoch_list, flag_server_types, flag_no_extra_req): if not flag_config_file: sys.exit("Must specify a config file") server_types = None epoch_list = None try:
#!/usr/bin/python2.4 #(c) 2002 Google inc # [email protected] # # Hups a server on a machine:port -- functiality of # server_requests.py.HupServerRequest # import sys from google3.pyglib import flags from google3.enterprise.legacy.setup import prodlib FLAGS = flags.FLAGS flags.DEFINE_string("machine", "", "The machine where the server runs") flags.DEFINE_integer("port", None, "The port for the server", lower_bound=0) 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") cmd = "kill -HUP `/usr/sbin/lsof -i :%s -t`" % FLAGS.port prodlib.RunAlarmRemoteCmdOrDie(FLAGS.machine, cmd, 120)
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' INSTALL_STATE_TO_MODE_MAP = {'ACTIVE': ACTIVE, 'TEST': TEST, 'SERVE': SERVE} # Borgmon constants BORGMON_BASE_PORT = 4911 BORGMON_TEST_PORT = 4912
import subprocess import tempfile import google3 from google3.pyglib import app from google3.pyglib import flags FLAGS = flags.FLAGS # Chrome OS CWP repo URL. # TODO(sque): move to a data file. GERRIT_URL = ("https://chromium.googlesource.com/chromiumos/platform2") CWP_PLATFORM2_PATH = "chromiumos-wide-profiling" flags.DEFINE_string("dest_path", "third_party/quipper", "Path to google3 quipper repo") flags.DEFINE_string( "source_path", "", "Path to upstream quipper directory if it already " "exists on the local filesystem") class QuipperImporter(object): """A class to sync quipper. Quipper is an opensource project that lives upstream. It is also used within Google. This class helps bring in upstream changes to google3. """ # These are files not to copy. # TODO(sque): move to a data file.
import repo_util from google3.pyglib import app from google3.pyglib import flags J2CL_WORKER_FLAGS = "--spawn_strategy=worker --internal_spawn_scheduler" PROFILE_OUT_LOCATION = "/tmp/j2cl-blaze-profile.out" WARM_UP_BUILDS = 30 FLAGS = flags.FLAGS flags.DEFINE_string( "target", None, "The target to build. It should have a j2cl_transpile target in it's " "dependencies.") flags.DEFINE_string("file", None, "The file to modify while testing reload time.") flags.DEFINE_integer("iterations", 40, "Number of times to rebuild the target.") class BlazeTargetBenchmarker(object): """The benchmark class.""" def __init__(self): self.current_working_dir = None def subprocess(self, command): subprocess.call(command, stdout=subprocess.PIPE,
# Config class. Now it is only in EntConfig # import sys from google3.pyglib import flags from google3.pyglib import logging from google3.enterprise.legacy.production.configmgr import server_requests from google3.enterprise.legacy.production.babysitter import validatorlib from google3.enterprise.legacy.adminrunner import entconfig from google3.enterprise.legacy.production.configmgr import configmgr_request FLAGS = flags.FLAGS flags.DEFINE_string("enthome", "", "The enterprise home") flags.DEFINE_string("restrict", "", "The name of the restrict") flags.DEFINE_string("value", "", "The repr() value of the parameter") flags.DEFINE_string("op", "", "add/del restrict") flags.DEFINE_integer("force", 0, "force the update") flags.DEFINE_integer("no_extra_req", None, "Do not write subsequent "\ "config manager requests (good for testing") true = 1 false = 0 def execute(flag_enthome, flag_restrict, flag_value, flag_op, flag_force, flag_no_extra_req): if not flag_restrict: sys.exit("Must specify a paramter")
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 def main(unused_argv): assert FLAGS.checkpoint_dir, '`checkpoint_dir` is missing.'
# import sys import string from google3.pyglib import flags from google3.enterprise.legacy.production.babysitter import config_factory from google3.enterprise.legacy.production.configmgr import server_requests from google3.enterprise.legacy.util import port_talker from google3.enterprise.legacy.production.babysitter import servertype 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_string("cmd", "", "The command to send to the server") flags.DEFINE_string( "expected_answer", "\nACKgoogle", "What we expect to get from the server in the case of succsee") flags.DEFINE_integer("no_extra_req", None, "Do not write subsequent "\ "config manager requests (good for testing") def execute(flag_config_file, flag_machine, flag_port, flag_cmd, flag_expected_answer, flag_no_extra_req): """ Provides the actual execution. Receives the flag values. All returns are OK, errors are on sys.exit
"""A class for reading NetCDF metadata and writes them to a csv file.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import csv import re import StringIO import tempfile import h5py from google3.pyglib import flags from google3.pyglib import gfile FLAGS = flags.FLAGS flags.DEFINE_string('file_type', 'rad', 'Corresponds to the type of file being extracted.') class NetCdfMetadataReader(object): """A class for reading NetCDF metadata and writes them to a csv file.""" def __init__(self, config_disc, file_type=None): """Constructor. Args: config_disc: Dictionary containing metadata mappings. file_type: Type of NetCDF file being parsed. """ if not file_type: self._file_type = FLAGS.file_type else: self._file_type = file_type
from google3.pyglib import logging from google3.enterprise.legacy.production.babysitter import validatorlib from google3.enterprise.legacy.install import install_utilities from google3.enterprise.tools import M from google3.pyglib import flags ############################################################################### FLAGS = flags.FLAGS flags.DEFINE_integer("max_startup_time_seconds", 15*60, "If adminrunner doesn't finish up its startup within this" " time it will be killed.") flags.DEFINE_string("profile_dir", "/export/hda3/tmp", "The directory where hotshot profile will be stored.") ############################################################################### ACK = "ACKgoogle" NACK = "NACKgoogle" ############################################################################## # small class to hold info about handler commands class CommandInfo: def __init__(self, num_params, num_lines, accept_body, method): self.num_params = num_params self.num_lines = num_lines self.accept_body = accept_body self.method = method
# * if specify the first line: #/usr/bin/python2 # it will appear as "./foo.py " using "ps -wwwwo cmd" # # 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
# 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.""" return re.compile(pattern_string).search(from_value).group(1)
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", "log", "fatal", "error", "warn", "info", "debug", "vlog"] ############################################################################## # Global variables
from google3.pyglib import flags from google3.walkabout.externalagents import api from google3.walkabout.externalagents.api import blip from google3.walkabout.externalagents.api import element from google3.walkabout.externalagents.api import errors from google3.walkabout.externalagents.api import events from google3.walkabout.externalagents.api import ops from google3.walkabout.externalagents.api import robot from google3.walkabout.externalagents.api import util FLAGS = flags.FLAGS for event in events.ALL: flags.DEFINE_string('eventdef_' + event.type.lower(), '', 'Event definition for the %s event' % event.type) def handle_event(src, bot, e, w): """Handle an event by executing the source code src.""" globs = { 'e': e, 'w': w, 'api': api, 'bot': bot, 'blip': blip, 'element': element, 'errors': errors, 'events': events, 'ops': ops, 'robot': robot,
from google3.enterprise.legacy.scripts import ent_service from google3.enterprise.legacy.util import port_talker 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)
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 into query_params and then stops serving. """ query_params = {}
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.') flags.DEFINE_string('config_file_path', None, 'Path to config file for NetCdf metadata.') flags.DEFINE_multi_string( 'file_types', ['mcm', 'rad'], ('The same purpose as file_type (singlular) but '
import re import tempfile import time from google3.pyglib import app from google3.pyglib import flags from google3.pyglib import logging from google3.enterprise.legacy.adminrunner import entconfig from google3.enterprise.legacy.adminrunner import adminrunner_client flags.DEFINE_list( 'langs', 'en', 'Comma separated list of language tags to ' 'generate spelling data for') flags.DEFINE_string('enthome', None, 'ENTHOME: the full path to the enterprise home directory') flags.DEFINE_integer('keep_spellingdata_for_days', 30, 'Keep spelling data for number of days') flags.DEFINE_integer( 'consolidate_spellingdata_interval', 24 * 60 * 60, 'Files written between this interval will be consolidated ' 'into one single file. In seconds.') FLAGS = flags.FLAGS # Used to extract unix timestamp from file names. ENTSPELLING_TIME_RE = re.compile(r'([^0-9]+-)([0-9]+)$')
import os import socket import stat import time import re from google3.enterprise.legacy.util import E from google3.enterprise.util import borgmon_util from google3.pyglib import flags from google3.pyglib import logging FLAGS = flags.FLAGS # TODO(erocke): figure out a way to not hard-code the default logs # directory. flags.DEFINE_string('logdir', '/export/hda3/logs', '') def SecsSinceMidnight(): '''Returns number of seconds since midnight.''' tups = time.localtime(time.time()) return tups[3] * 3600 + tups[4] * 60 + tups[5] def GetHttpResponse(data): '''generic method to get result from a POST operation''' try: host = 'localhost' port = 2100 url = '/legacyCommand' postData = '%s\n' % data h = httplib.HTTPConnection(host, port)
""" __author__ = '[email protected] (Pierre-Antoine Manzagol)' import google3 from google3.pyglib import app from google3.pyglib import flags import sys import matplotlib #matplotlib.verbose.set_level('debug') matplotlib.use('Agg') from matplotlib import pylab import numpy from google3.experimental.popnnet.scripts import visualizing flags.DEFINE_string("dir", "", "location where to find the input files") FLAGS = flags.FLAGS def main(argv): #if len(argv) < 4: # print """Usage: # """ # sys.exit(1) #nlayers = int(argv[1]) # get number of layers f = open(FLAGS.dir + "weights/nlayers.txt") nlayers = int(f.readlines()[0]) f.close()
#(c) 2002 Google inc # [email protected] # # Restarts everything # import sys import os from google3.pyglib import flags from google3.enterprise.legacy.production.babysitter import config_factory true = 1 false = 0 FLAGS = flags.FLAGS flags.DEFINE_string("config_file", "", "The configuration file") 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.config_file: sys.exit("Config file must be specified") cp = config_factory.ConfigFactory().CreateConfig(FLAGS.config_file) if not cp.Load(): sys.exit("Unable to load config file %s" % (cp.GetConfigFileName()))
from google3.enterprise.legacy.util import C import threading from google3.enterprise.core import core_utils from google3.enterprise.legacy.install import install_utilities from google3.enterprise.legacy.adminrunner import reset_index ############################################################################### true = 1 false = 0 ############################################################################## FLAGS = flags.FLAGS flags.DEFINE_integer("port", 2100, "") flags.DEFINE_integer("reset_status_cache_timeout", 60, "") flags.DEFINE_string("enthome", E.getEnterpriseHome(), "") flags.DEFINE_string("installstate", None, "") flags.DEFINE_string("box_keys_dir", None, "") flags.DEFINE_string("license_keys_dir", None, "") ############################################################################## def StartupWork(cfg, state): try: ############################################################################# # check memory-total logging.info("check memory-total") if not cfg.CheckMachineMemory(): logging.fatal("failed to check memory-total") return
import time from google3.pyglib import flags from google3.pyglib import logging from google3.enterprise.legacy.scripts import ent_service from google3.enterprise.legacy.util import C from google3.enterprise.legacy.util import E from google3.enterprise.legacy.util import fed_network_config from google3.enterprise.legacy.util import fed_network_util from google3.enterprise.legacy.util import fed_stunnel_config from google3.enterprise.legacy.util import stunnel_jail from google3.enterprise.license import license_api # Command flags flags.DEFINE_string('command', 'DEFAULT', 'Command to execute') flags.DEFINE_string('appliance_id', 'ALL', 'Appliance Id to connect to') flags.DEFINE_string('deb', 0, 'debug mode') FLAGS = flags.FLAGS FEDERATION_NETWORK_CONFIG = '%s/local/conf/fed_network.xml' # Executable for corpus root generation FEDERATION_SUPERROOT_CONFIG_BIN = '%s/local/google/bin/fed_superroot_config.par' FEDERATION_CONFIGROOT_TEMPLATE = ('%s/local/googledata/enterprise/data/' 'federation_root_template') FEDERATION_CONFIGROOT_FILE = ('%s/local/googledata/enterprise/data/' 'federation_root.cfg') class FederationNetworkClientService(ent_service.ent_service):
# Restarts/kills a server that runs on a porton a machine using a specified # config file (implements server_requests.RestartServerRequest) # 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)
# (c) 2002 Google inc # [email protected] # # This contains the code to create multiple request of the seame kind but # differentaited on machines based of servertype flag # import sys from google3.pyglib import flags from google3.enterprise.legacy.production.babysitter import config_factory from google3.enterprise.legacy.production.babysitter import servertype from google3.enterprise.legacy.production.configmgr import autorunner FLAGS = flags.FLAGS flags.DEFINE_string("config_file", "", "The configuration file") flags.DEFINE_string("data", "", "The repr for data of subsequent requests") flags.DEFINE_string("servertype", "", "Generate reuqests for this type") flags.DEFINE_string("machineparam", "", "The machine parameter for requests") flags.DEFINE_string("portparam", "", "The port parameter for requests") flags.DEFINE_integer("no_extra_req", None, "Do not write subsequent "\ "config manager requests (good for testing") def execute(flag_config_file, flag_data, flag_servertype, flag_machineparam, flag_portparam, flag_no_extra_req): if not flag_servertype: sys.exit("Must specify a servertype") if not flag_machineparam: sys.exit("Invalid machine param") if not flag_portparam: sys.exit("Invalid port param") data = None