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( "ramp", None, "Gradually increase voltage to prevent " "tripping Monsoon overvoltage")
# 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")
# # 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: exec("server_types = %s" % flag_server_types)
from google3.enterprise.legacy.adminrunner import adminrunner_server from google3.pyglib import flags 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")
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: exec("server_types = %s" % flag_server_types) exec("epoch_list = %s" % flag_epoch_list) except: sys.exit("Invalid value %s or %s" % (flag_server_types, flag_epoch_list)) cp = config_factory.ConfigFactory().CreateConfig(flag_config_file)
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]+)$') class Error(Exception): pass
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 ' 'it needs to match the list of locations. ' 'This is a multi-string Flag, used multiple times .')) flags.DEFINE_multi_string( 'locations', ['ABI-L2-MCMIPM/2017/*/*/*.nc', 'ABI-L1b-RadM/2017/*/*/*.nc'], ('Subdirectories for Data Locations to Be Walked. '
import google3 # Required to enable third-party import magic. import hotshot # Third-party import. See ThirdPartyPython wiki. 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
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' INSTALL_STATE_TO_MODE_MAP = {'ACTIVE': ACTIVE, 'TEST': TEST, 'SERVE': SERVE} # Borgmon constants
_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",
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, stderr=None, shell=True, cwd=self.current_working_dir) def blaze_build(self, blaze_target):
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 """
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") 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
############################################################################### FLAGS = flags.FLAGS flags.DEFINE_string("configmgr_request_dir", "", "The directory with requests") flags.DEFINE_string("working_dir", "", "Working directory") flags.DEFINE_string("staging_dir", default_staging_dir, "Staging directory for called scripts") flags.DEFINE_string("replication_machines", "", "Comma sepparated list of machines to replicate to") flags.DEFINE_string("logfile", "/tmp/ent_configmgr", "Where to send the output log messages") flags.DEFINE_string( "cwd", "", "Working Directory, if non empty we change to this directory") flags.DEFINE_integer("port", 0, "healthz port") ############################################################################### FOREVER = 100000000 MANY_TIMES = 100 HUP_SERVER_COMMAND_INFO = { autorunner.COMMAND: './hup_server.py', autorunner.EXTRA_CMD_ARGS: [], autorunner.RETRIES: FOREVER, autorunner.CLASS: server_requests.HupServerRequest, } RESTART_SERVER_COMMAND_INFO = { autorunner.COMMAND: './restart_server.py',
FLAGS = flags.FLAGS flags.DEFINE_string('instance', '/cloudsql/google.com:cicentcom:us-central1:gtech-feeds', 'Cloud SQL instance Name') flags.DEFINE_string('user', 'cianalysismysql', 'Username for Cloud SQL instance.') # MySQL root password here: # https://valentine.corp.google.com/#/show/1507228762951889?tab=metadata flags.DEFINE_string('password', '', 'Password to use for Cloud SQL instance.') flags.DEFINE_string( 'database', 'CpdNetCdf', 'Name of the Cloud SQL database to use for Cloud ' 'SQL instance.') flags.DEFINE_integer('connect_retries', 5, 'Max number of DB connect retries before failing.') flags.DEFINE_string('table_name', 'netcdf_metadata', 'Name of the Cloud SQL table to use for Cloud') flags.DEFINE_string('project_name', 'Test', 'Name of the Cloud SQL table to use for Cloud') class TrackingDB(object): """Class to connect and manage DB of filenames already processed.""" def __init__(self): """Constructor.""" if not FLAGS.instance: raise app.UsageError('--instance must be specified') unix_socket = FLAGS.instance