Ejemplo n.º 1
0
def configer():
    with open("config") as f:
        raw_config = f.read()

    parser = config_parser.ConfigParser(raw_config)

    config = config_checker.ConfigModifier(
        parser.data, config_parser.Config(cmdargs.__dict__))()
    return config
Ejemplo n.º 2
0
def main():
    """main function"""
    usage = ("python modules/data/tools/recorder/data_recorder_manager.py -c "
             "modules/data/conf/recorder.conf")
    parser = optparse.OptionParser(usage)
    parser.add_option("-c",
                      "--conf",
                      dest="conf_file",
                      help="Specific data recorder config file")
    parser.add_option("-v",
                      "--version",
                      action="store_true",
                      dest="my_version",
                      default=False,
                      help="Show the version of this program")
    (options, args) = parser.parse_args()

    if len(sys.argv) == 1:
        parser.error("Incorrect numbers of arguments")
    if len(args):
        parser.error("Incorrect numbers of arguments, "
                     "please type python data_recorder.py -h")

    if options.my_version:
        return print_version(G_VERSION)

    if options.conf_file is not None:
        if not os.path.exists(options.conf_file):
            parser.error(
                "The config file you given does not exists, please check!")
        else:
            cp = config_parser.ConfigParser()
            global_conf = cp.load_config(
                "modules/data/conf/recorder.global.yaml")
            task_conf = cp.load_config(options.conf_file)
            if global_conf is None:
                print("Load recorder.global.yaml error!")
                sys.exit(-1)
            if task_conf is None:
                print("Load recorder.debug.yaml error!")
                sys.exit(-1)
            if not cp.get_global_config(global_conf) == 0:
                print("Get global parameters from "
                      "modules/data/conf/recorder.global.yaml "
                      "encounters error!")
                sys.exit(-1)
            if not cp.get_task_from_yaml(task_conf) == 0:
                print("Get task parameters from %s encounters error!" %
                      (options.conf_file))
            rospy.init_node('data_recorder', anonymous=False)
            launch_data_recorder(cp)

    return 0
Ejemplo n.º 3
0
 def __init__(self, config_xml):
     """
     config_xml should be full path to XML'
     """
     # state = MyWorkflow()  #google Pylint False Positive E1101
     self.xml = config_xml
     try:
         self.my_parser = config_parser.ConfigParser(self.xml)
     except:
         log._error(
             "Unable to use given path to input XML, please check the path for errors"
         )
         exit(0)
Ejemplo n.º 4
0
def main():
    bot_info = GetBotInfo()

    print 'Bot info: %s' % bot_info
    copy_path = GetPackageCopy(bot_info)
    config_file = os.path.join(copy_path, '.test_config')
    test_config = config_parser.ConfigParser(config_file)
    test_config.replacements = {
        'dart': utils.CheckedInSdkExecutable(),
        'project_root': copy_path,
        'python': sys.executable
    }

    RunCustomScript(test_config) or \
      RunDefaultScript(bot_info, test_config, copy_path)
Ejemplo n.º 5
0
def main(argv):
    try:
        argv[1]
    except IndexError:
        print "usage {0} <configfile>"
        sys.exit(2)

    parser = config_parser.ConfigParser()
    configfile = argv[1]
    parser.read_config_file(configfile)

    file_temp = '''
#!/bin/sh
'''
    terminals = parser.get_terminals()

    for term in terminals:
        file_temp += create_func(term)

    print file_temp
Ejemplo n.º 6
0
import config_parser
import file_manager

if __name__ == "__main__":
    p = config_parser.ConfigParser()
    f = file_manager.FileManager()

    dest = p.get_destination()
    f.archive_desktop_files(dest)
Ejemplo n.º 7
0
                gatewayaddress = line.split('   ')[4]
                break
        mlines = interconnectdata.split('\n')
        for line in mlines:
            if "Yes" in line:
                interconnectstartaddress = line.split('   ')[2]
                break
        finaldata = [
            serverstartaddress, subnetmaskaddress, gatewayaddress,
            interconnectstartaddress
        ]
        return finaldata


if __name__ == '__main__':
    p = config_parser.ConfigParser('testcase\ConfigMgr.xml')
    p.parse_xml()
    p.store_xml_data()
    for oa in p.oa_list:
        print(oa.ip_address, oa.username, oa.password, oa.gateway,
              oa.enable_ebipa, oa.subnet, oa.server_start_addr,
              oa.inter_start_addr, oa.reset_vc_module)

    oaconfig = OA(oa.ip_address, oa.username, oa.password)

    oaconfig.get_blade_info("show server info all")
    oaconfig.set_ebipa_for_interconnect(oa.inter_start_addr, oa.subnet)
    oaconfig.set_ebipa_servers(oa.server_start_addr, oa.subnet)
    oaconfig.set_ebipa_server_and_inter_gateway(oa.gateway)
    oaconfig.enable_ebipa_for_interconnect()
    oaconfig.enable_ebipa_for_server()
Ejemplo n.º 8
0
 def setUp(self):
     self.uut = config_parser.ConfigParser(yaml.load(self.yaml_string))
Ejemplo n.º 9
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import requests
import sys
import config_parser as cp

configs = cp.ConfigParser()


def parse_city():
    city = sys.argv[1]
    return city


def request_city_info(city):
    api_address = configs.get_api_address()
    request_params = {
        "q": city,
        "APPID": configs.get_api_key(),
        "units": "metric",
    }
    api_response = requests.get(api_address, params=request_params)
    return api_response


def validate_api_response(response):
    if response.status_code == 200:
        return True
    else:
        return False