コード例 #1
0
 def test_read_file_simple_no_include(self):
     temp = tempfile.NamedTemporaryFile()
     try:
         cfg1 = cfg.Config(inp_4)
         temp.write(outp_4.encode("UTF-8"))
         temp.flush()
         cfg2 = cfg.Config()
         cfg2.read_file(temp.name)
         self.assertDictEqual(cfg1.__dict__, cfg2.__dict__)
     finally:
         temp.close()
コード例 #2
0
    def read_config(self):
        """
        This function gets configuration file. It checks if the file exists and parses it into an object.

        Parameters
        ----------
        config_file : str
            configuration file name, including path

        Returns
        -------
        config_map : Config object
            a Config containing parsed configuration, None if the given file does not exist
        """
        if os.path.isfile(self.config_file):
            try:
                with open(self.config_file, 'r') as f:
                    config_map = cfg.Config(f.read())
                    return (True, config_map)
            except Exception as e:
                msg = 'cannot parse configuration file', self.config_file, e
                return (False, msg)
        else:
            msg = 'configuration file', self.config_file, 'does not exist'
            return (False, msg)
コード例 #3
0
def load_detections_pom(seq_path,
                        start_fid,
                        end_fid,
                        p_threshold=1e-4,
                        scale=1.0):
    '''
    seq_path - path with the pom output for the sequence
    start_fid, end_fid - frame range
    p_threshold - do not load detections below this probability
    scale - resize the bounding box'''

    seq_tag = os.path.basename(os.path.normpath(seq_path))
    room = libcfg.Config(open(seq_path + '%s.cfg' % seq_tag).read()).room
    bboxes = load_bboxes_pom(seq_path + 'bboxes.txt', scale)
    dets = {}
    for fid in range(start_fid, end_fid):
        dets[fid] = {}
        for l in open(seq_path + 'pom/%06d.txt' % fid).readlines():
            lid, prob = map(float, l.split('\t'))
            if prob > p_threshold:
                tid = len(dets[fid])
                pw = pom.lid_to_world(lid, room.plane.cols, room.plane.rows,
                                      room.plane.cell_width,
                                      room.plane.cell_height)
                dets[fid][tid] = {
                    'location': lid,
                    'pw': pw,
                    'bbox': bboxes[lid],
                    'confidence': prob
                }
    return dets
コード例 #4
0
ファイル: guard.py プロジェクト: apsys16-p10/falcon
def cfg_init(fname):
	global RSYNC_CMD,RSYNC_USER,NODE_INFO
	RSYNC_USER = os.getlogin()
	fsize = 4096 # max size of a cfg
	if os.path.exists(fname):
		f = open(fname,'r')
		buff = f.read(fsize)	
		conf = cfg.Config(buff)
		node_info = conf.consensus_config
		NODE_INFO = node_info
		#print "[cfg_init] ", node_info	
		# update rsync
		try:
			self_conf = node_info[SELF_ID]	
			self_ip = self_conf.ip_address
			#"rsync -aP --delete %s [email protected]:%s ; rsync -aP --delete %s [email protected]:%s"%(STORE_BASE,STORE_UPPER,STORE_BASE,STORE_UPPER)
			rsync_option="rsync -aP --delete "
			RSYNC_CMD=""
			for item in node_info:
				if item.ip_address != self_ip: # replicas
					RSYNC_CMD=RSYNC_CMD + rsync_option + STORE_BASE +" %s@%s:%s ; "%(RSYNC_USER,item.ip_address,STORE_UPPER)	
		except Exception as e:
			print "[cfg_init] configuration error. exit"
			exit()
		print "[cfg_init] rsync_cmd: %s"%(RSYNC_CMD)
	else:
		print "[cfg_init] %s is not found. I will exit."%(fname)
コード例 #5
0
	def GET(self, srv_id):
		help.check_access()

		# Get Server Information
		Server = list(db().executeLiteral( "SELECT * FROM servers WHERE srv_id = ?", [srv_id])[0])
		if Server[1] == 0:
			Server = ["N/A"] + Server
		else:
			name = db().executeLiteral( "SELECT name FROM environments WHERE eid = ?", [Server[1]])[0][0]
			Server = [name] + Server

		# Get Service information for the server
		Services = db().execute( "Server_Details", 1, [Server[1]])
		data = []
		for ser in Services:
			result = Logger().getAnalytics( srv_id, ser[0] )
			data.append( [ser[2], ser[1], result[2], result[3], result[4], str( result[0] ) + '-' + str( result[1] )] )

		path = join("./configs/", srv_id)
		file_reader = open( path, "r")
		master = cfg.Config( file_reader.read() )
		file_reader.close()

		masterInfo = [['Analytics Server' , master.Analytic_Settings.items()]
					, ['Management Server', master.Management_Settings.items()]
					, ['Data Logger', master.Logging.items()]]

		return help.renderPage("Server Details", render.server_details( Server, data, masterInfo ))
コード例 #6
0
ファイル: bend.py プロジェクト: xsilvertom/smithproxy
    def load_sx_file(sx_file):

        s = cfg.Config()
        with open(sx_file, 'r') as myfile:
            flat_file = myfile.read()
        s.read_string(flat_file)

        return flat_file, s
コード例 #7
0
ファイル: ldapaaa.py プロジェクト: xsilvertom/smithproxy
def load_config(fnm):
    try:
        c = cfg.Config()
        c.read_file(fnm)
        return c

    except Exception, e:
        print "Error loading file: " + str(e)
コード例 #8
0
ファイル: backend.py プロジェクト: ardnet/genesis
 def load(self):
     cfg_str = ConfManager.get().load('umurmur', self.config_file)
     try:
         self.config = pylibconfig2.Config(cfg_str)
     except pylibconfig2.PyLibConfigErrors as e:
         self.app.log.error(e)
     if not self.config.lookup('arkos_init'):
         self.config.arkos_init = True
         self.config.welcometext = arkos_welcome
コード例 #9
0
ファイル: online_pnl_plot.py プロジェクト: yssource/quant
def GetHedge(path):
    f = open(path)
    setting = cfg.Config(f.read())
    f.close()
    #print [setting.lookup('strategy')[i].pairs[1] for i in range(len(setting.lookup('strategy')))]
    return [
        setting.lookup('strategy')[i].pairs[1]
        for i in range(len(setting.lookup('strategy')))
    ]
コード例 #10
0
 def test_read_file_include(self):
     temp1 = tempfile.NamedTemporaryFile()
     temp2 = tempfile.NamedTemporaryFile()
     inc1 = '@include "' + temp2.name + '"'
     try:
         cfg1 = cfg.Config(outp_5)
         temp1.write(inc1.encode("UTF-8"))
         temp1.write(intp_5.encode("UTF-8"))
         temp1.flush()
         temp2.write(intp_6.encode("UTF-8"))
         temp2.flush()
         cfg2 = cfg.Config()
         cfg2.read_file(temp1.name)
         cfg3 = cfg.Config(outp_6)
         self.assertDictEqual(cfg1.__dict__, cfg2.__dict__)
         self.assertDictEqual(cfg3.__dict__, cfg2.__dict__)
     finally:
         temp1.close()
         temp2.close()
コード例 #11
0
ファイル: online_pnl_plot.py プロジェクト: yssource/quant
def HandleContractConfig(path):
    f = open(path)
    setting = cfg.Config(f.read()).lookup('map')
    for s in setting:
        ticker = s.ticker
        deposit_rate[ticker] = float(s.deposit_rate)
        open_fee_rate[ticker] = float(s.open_fee_rate)
        close_today_rate[ticker] = float(s.close_today_fee_rate)
        close_rate[ticker] = float(s.close_fee_rate)
        contract_size[ticker] = int(s.contract_size)
        min_price_move[ticker] = float(s.min_price_move)
コード例 #12
0
def get_config_by_dir(simdir):
    '''
    Get the libconfig object from ```simdir`/out.cfg''.
    '''
    cfgfname = os.path.join(simdir, 'out.cfg')
    if not os.path.exists(cfgfname):
        raise ValueError('{}: get_config_by_dir: invalid simdir {}, '
                         'no cfg file {} found'
                         .format(PACKAGE_NAME, simdir, cfgfname))
    with open(cfgfname, 'r') as fh:
        cfg = lcfg.Config(fh.read())
    return cfg
コード例 #13
0
ファイル: CXDVizNX.py プロジェクト: bfrosik/cdi
    def __init__(self, config):
        """
        The constructor gets config file and fills out the class members.

        Parameters
        ----------
        conf : str
            configuration file name

        Returns
        -------
        none
        """
        if os.path.isfile(config):
            with open(config, 'r') as f:
                config_map = cfg.Config(f.read())
        deg2rad = np.pi / 180.0
        try:
            self.lamda = config_map.lamda
        except AttributeError:
            print ('lamda not defined')
        try:
            self.delta = config_map.delta * deg2rad
        except AttributeError:
            print ('delta not defined')
        try:
            self.gamma = config_map.gamma * deg2rad
        except AttributeError:
            print ('gamma not defined')
        try:
            self.arm = config_map.arm
        except AttributeError:
            print ('arm not defined')
        try:
            self.dth = config_map.dth
        except AttributeError:
            print ('dth not defined')
        try:
            pixel = config_map.pixel
            self.dpx = pixel[0] / self.arm
            self.dpy = pixel[1] / self.arm
        except AttributeError:
            print ('pixel not defined')
        try:
            self.save_two_files = config_map.save_two_files
        except AttributeError:
            print ('save_two_files not defined')
        try:
            self.crop = config_map.crop
        except AttributeError:
            self.crop = None
            print ('crop not defined')
コード例 #14
0
ファイル: bend.py プロジェクト: xsilvertom/smithproxy
    def load_users_file(user_file):
        u = cfg.Config()

        flat_file = None
        config_struct = None

        with open(user_file, 'r') as myfile:
            flat_file = myfile.read()

        u.read_string(flat_file)
        config_struct = u

        return flat_file, config_struct
コード例 #15
0
ファイル: webfr.py プロジェクト: xsilvertom/smithproxy
def run_portal_all_background():

    c = cfg.Config()
    c.read_file("/etc/smithproxy/smithproxy.cfg")

    for ps_name, callable in [("http", run_plaintext), ("https", run_ssl)]:
        r, w = os.pipe()
        pid = os.fork()

        if pid == 0:
            continue
        else:
            logging.debug("Starting %s process..." % (ps_name, ))
            callable(c)
            time.sleep(1)
コード例 #16
0
ファイル: build_rules.py プロジェクト: poupas/dpdk-firewall
def main():
    if len(sys.argv) < 3:
        print("usage: {} <firewall_config> <zone_config>".format(sys.argv[0]))
        print("example: {} pipeline.conf {}/example.conf".format(
            sys.argv[0], ZONE_PATH))
        return -1

    conf_path = sys.argv[1]
    rule_path = sys.argv[2]

    try:
        config = cfg.Config(open(conf_path, 'rb').read())
    except (EnvironmentError, cfg.ParseException,
            cfg.ParseFatalException) as err:
        print("Could not load configuration file: {}".format(err))
        return -1

    zname = os.path.basename(rule_path).split('.')[0]

    cfgp = ConfigParser(config)
    rules = NFTRuleParser(rule_path, cfgp.ipaddrs(zname), cfgp.ip6addrs(zname))
    rules.parse()

    zone = Zone(zname, rules)
    serializer = RuleSerializer(zone)

    for acl in zone.rules.ip_acl:
        for nat in zone.rules.ip_nat:
            # Destination NAT
            if acl.dnet_contains(nat.orig_ip):
                if acl.iphdr.dnet.hostmask != ipaddress.IPv4Address(
                        u'0.0.0.0'):
                    raise AssertionError(
                        'ACL rules which are NATed must refer to a single '
                        'destination host. {} is not valid.'.format(
                            acl.iphdr.dnet))
                acl.dnat = nat
                acl.action |= ACL_ACTION_DNAT

    for acl in zone.rules.ip_acl:
        serializer.write(acl)
    for acl in zone.rules.ip6_acl:
        serializer.write(acl)
    for nat in zone.rules.ip_nat:
        serializer.write(nat)

    return 0
コード例 #17
0
    def load_config(self):

        #### Logging might not be enabled yet at this stage so
        #### be careful where you send the log messages

        self.cfgfilepath = normalize_path(self.textctrl_configfile.GetValue())
        try:
            self.cfg = pycfg.Config()
            self.cfg.read_file(self.cfgfilepath)

            self.print_to_console(
                "Successfully loaded configuration file \"%s\".\n" %
                self.cfgfilepath)

            #### Load network config ####

            if self.cfg.lookup('network.address'):
                #self.textctrl_host.Clear()
                self.textctrl_connection_host.ChangeValue(
                    self.cfg.network.address)
            else:
                self.print_to_console(
                    "No rover host address specified in config file.\n")

            if self.cfg.lookup('network.port_command'):
                #self.textctrl_port_cmd.Clear()
                self.textctrl_connection_port_cmd.ChangeValue(
                    str(self.cfg.network.port_command))
            else:
                self.print_to_console(
                    "No rover command port specified in config file.\n")

            if self.cfg.lookup('network.video_url'):
                self.textctrl_connection_video_url.ChangeValue(
                    str(self.cfg.network.video_url))
            else:
                self.print_to_console(
                    "No rover video port specified in config file.\n")

            #### Load Keymap ####

            self.load_keymap()

        except Exception as e:
            self.print_to_console(
                'Error: could not load config file \"%s\" (%s).\n' %
                (self.cfgfilepath, e))
コード例 #18
0
ファイル: makecerts.py プロジェクト: xsilvertom/smithproxy
def load_sans_from_config(configfile):

    sans = []
    ips = []

    try:
        import pylibconfig2 as cfg

        sxcfg = cfg.Config()
        sxcfg.read_file(configfile)

        portal_addr = None
        try:
            portal_addr = sxcfg.settings.auth_portal.address
            ipaddress.ip_address(portal_addr)
            print("cfg portal address is IP")
            ips.append(portal_addr)
        except ValueError:
            # ip is not recognized
            sans.append(portal_addr)
        except AttributeError:
            # config is not found
            pass

        portal_addr6 = None
        try:
            portal_addr6 = sxcfg.settings.auth_portal.address6
            ipaddress.ip_address(portal_addr6)
            print("cfg portal address6 is IP")
            ips.append(portal_addr6)
        except ValueError:
            # ip is not recognized
            sans.append(portal_addr6)
        except AttributeError:
            # config is not found
            pass

    except ImportError as e:
        print(
            "... cannot load pylibconfig2 - cannot specify exact portal FQDN")

    return [sans, ips]
コード例 #19
0
ファイル: utils.py プロジェクト: AdvancedPhotonSource/cdi
def read_config(config):
    """
    This function gets configuration file. It checks if the file exists and parses it into an object.
    
    Parameters
    ----------
    config : str
        configuration file name, including path
        
    Returns
    -------
    config_map : Config object
        a Config containing parsed configuration, None if the given file does not exist
    """
    if os.path.isfile(config):
        with open(config, 'r') as f:
            config_map = cfg.Config(f.read())
            return config_map
    else:
        return None
コード例 #20
0
def change_name_and_write(value_update, old_conf, new_conf_file_handle):
    new_conf = pylibconfig2.Config()
    found_key = False
    for this_old_key in value_update.acceptable_keys():
        if old_conf.get(this_old_key) != None:
            old_value = old_conf.lookup(this_old_key)
            if this_old_key == value_update.key():
                new_value = old_value
            else:
                new_value = value_update.function()(old_value)
            new_conf.set(value_update.key(), new_value)
            found_key = True
            break
    if not found_key:
        if value_update.default_value() != None:
            new_conf.set(value_update.key(), value_update.default_value())
        else:
            raise ValueError("Configuration file must contain {0}".format(
                value_update.key()))
    new_conf_file_handle.write(str(new_conf) + "\n")
コード例 #21
0
def load_detections_pom_3d(seq_path,
                           start_fid,
                           end_fid,
                           p_threshold=1e-4,
                           scale=1.0):
    '''
    seq_path - path with the pom output for the sequence
    start_fid, end_fid - frame range
    p_threshold - do not load detections below this probability
    scale - resize the bounding box'''

    seq_tag = os.path.basename(os.path.normpath(seq_path))
    room = libcfg.Config(open(seq_path + '%s.cfg' % seq_tag).read()).room

    rows = room.cube.rows
    cols = room.cube.cols
    size = room.cube.size

    def lid_to_world_3d(lid):
        z = int(lid) / (rows * cols)
        y = (int(lid) - z * (rows * cols)) / rows
        x = (int(lid) - z * (rows * cols)) % rows
        return np.array([(x + 0.5) * size, (y + 0.5) * size, (z + 0.5) * size,
                         1.0])

    bboxes = load_bboxes_pom(seq_path + 'bboxes.txt', scale)
    dets = {}
    for fid in range(start_fid, end_fid):
        dets[fid] = {}
        for l in open(seq_path + 'pom/%06d.txt' % fid).readlines():
            lid, prob = map(float, l.split('\t'))
            if prob > p_threshold:
                tid = len(dets[fid])
                pw = lid_to_world_3d(lid)
                dets[fid][tid] = {
                    'location': lid,
                    'pw': pw,
                    'bbox': bboxes[lid],
                    'confidence': prob
                }
    return dets
コード例 #22
0
    def setUp(self):
        # Example sim directory.
        self.simdir = os.path.join(
            os.path.abspath(os.path.dirname(__file__)),
            'simdir')
        # Create config.
        self.cfg = lcfg.Config('g1 = {s1 = {t1 = 1; t2 = "val";}} '
                               'g2 = (0, 1, 2); '
                               'g3 = 3;')

        # Create temp file.
        self.fhdl = NamedTemporaryFile(suffix='.h5')
        # Create file object.
        self.fobj = h5py.File(self.fhdl.name, 'r+')
        # Create the datasets.
        dtype = np.dtype([('g1', np.dtype([('t1', 'u8', (100,)),
                                           ('t2', 'u8')])),
                          ('g2', 'u8', (10, 10))])
        dset = np.array(((np.ones(100),
                          10),
                         np.zeros((10, 10))),
                        dtype=dtype)
        self.fobj.create_dataset('root', data=dset)
コード例 #23
0
ファイル: webfr.py プロジェクト: xsilvertom/smithproxy
def run_portal_ssl(tenant_name, tenant_idx, drop_privs_routine=None):
    global TENANT_NAME, TENANT_IDX, flog
    TENANT_NAME = tenant_name
    TENANT_IDX = tenant_idx
    flog = create_portal_logger('portal_ssl.%s' % (tenant_name, ))

    os.environ['TENANT_NAME'] = tenant_name
    os.environ['TENANT_IDX'] = tenant_idx

    ret = True
    try:
        flog.info("SSL portal: start")
        c = cfg.Config()
        c.read_file("/etc/smithproxy/smithproxy.cfg")

        if drop_privs_routine:
            flog.info("dropping privileges")
            drop_privs_routine()
            flog.info("done")

        run_ssl(c)
    except Exception, e:
        ret = False
        flog.error("run_portal_ssl: exception caught: %s" % (str(e)))
コード例 #24
0
ファイル: GetFee.py プロジェクト: yssource/quant
def Read(config_path=config_path):
    setting = cfg.Config(open(config_path).read()).lookup('map')
    for s in setting:
        ticker = s.ticker
        print 'handling ' + ticker
        is_fixed_open_fee_rate[ticker] = bool(s.is_fixed_open_fee_rate)
        is_fixed_close_fee_rate[ticker] = bool(s.is_fixed_close_fee_rate)
        is_fixed_close_today_fee_rate[ticker] = bool(
            s.is_fixed_close_today_fee_rate)
        if is_fixed_open_fee_rate[ticker]:
            open_fee[ticker] = float(s.open_fee)
        else:
            open_fee_rate[ticker] = float(s.open_fee_rate)
        if is_fixed_close_fee_rate[ticker]:
            close_fee[ticker] = float(s.close_fee)
        else:
            close_fee_rate[ticker] = float(s.close_fee_rate)
        if is_fixed_close_today_fee_rate[ticker]:
            close_today_fee[ticker] = float(s.close_today_fee)
        else:
            close_today_fee_rate[ticker] = float(s.close_today_fee_rate)
        deposit_rate[ticker] = float(s.deposit_rate)
        contract_size[ticker] = int(s.contract_size)
        min_price_move[ticker] = float(s.min_price_move)
コード例 #25
0
import os
import numpy as np
from matplotlib import cm
import pylibconfig2
from ergoPack import ergoPlot

configFile = '../cfg/transferCZ.cfg'
cfg = pylibconfig2.Config()
cfg.read_file(configFile)
fileFormat = cfg.general.fileFormat

# Transition lag
if (hasattr(cfg.stat, 'tauDimPlot')):
    tauDim = cfg.stat.tauDimPlot
else:
    tauDim = cfg.transfer.tauRng[0]

timeScaleConversion = 1. / 12
dimObs = len(cfg.caseDef.indicesName)
nSeeds = len(cfg.caseDef.seedRng)

nev = cfg.spectrum.nev
evPlot = np.array([0])
plotForward = True
plotBackward = False
xmin = 24.5
xmax = 29.
ymin = 90.
ymax = 160.
cbar_format = '{:.2e}'
evPlot = np.array([1, 2, 3, 4, 5, 6])
コード例 #26
0
        while self.queue_console.empty() == False:
            print 'something in console'
            res.append(self.queue_console.get())
            self.queue_console.task_done()
        return res

    def fetch_status_updates(self):
        pass

    def is_rover_connected(self):
        if self.events['comms_enable'].is_set():
            return not self.events['comms_server_disconnect'].is_set()
        else:
            return False

    def close(self):
        self.events['comms_enable'].clear()
        self.comms_flush_rxtx_queues()
        self.comms_close()


if __name__ == "__main__":

    cfgfilepath = sys.argv[1]

    cfg = pycfg.Config()
    cfg.read_file(cfgfilepath)
    cm = ClientMaster(cfg=cfg)
    cm.start()
    #cm.join()
コード例 #27
0
 def load_config(self):
     self.cfg = cfg.Config()
     self.cfg.read_file("/etc/smithproxy/smithproxy.cfg")
コード例 #28
0
def setup_rundirs(prefix, scan, conf_dir, **kwargs):
    """
    Concludes the experiment directory, creates main configuration files, and calls function to copy other configuration files.

    Parameters
    ----------
    prefix : str
        prefix to name of the experiment/data reconstruction
    scan : str
        a range of scans to prepare data from
    conf_dir : str
        directory from where the configuration files will be copied
    specfile : str
        optional, from kwargs, specfile configuration to write to config file
    copy_prep : bool
        optional, from kwargs, if sets to true, the prepared file is also copied
        
    Returns
    -------
    nothing
    """
    id = prefix + '_' + scan

    if not os.path.isdir(conf_dir):
        print('configured directory ' + conf_dir + ' does not exist')
        return

    main_conf = os.path.join(conf_dir, 'config')
    if not os.path.isfile(main_conf):
        print('the configuration directory does not contain "config" file')
        return

    if not ver.ver_config_prep(main_conf):
        return

    try:
        with open(main_conf, 'r') as f:
            config_map = cfg.Config(f.read())
    except Exception as e:
        print('Please check the configuration file ' + main_conf +
              '. Cannot parse ' + str(e))
        return

    try:
        working_dir = config_map.working_dir.strip()
    except:
        working_dir = os.getcwd()

    experiment_dir = os.path.join(working_dir, id)
    if not os.path.exists(experiment_dir):
        os.makedirs(experiment_dir)
    # copy config_data, config_rec, cofig_disp files from cofig directory into the experiment conf directory
    experiment_conf_dir = os.path.join(experiment_dir, 'conf')
    if not os.path.exists(experiment_conf_dir):
        os.makedirs(experiment_conf_dir)

    # here we want the command line to be used if present, so need to check if None was passed or not.
    if 'specfile' in kwargs:
        specfile = kwargs['specfile']
    if specfile is None:
        try:
            specfile = config_map.specfile.strip()
        except:
            print("Specfile not in config or command line")

    # Based on params passed to this function create a temp config file and then copy it to the experiment dir.
    experiment_main_config = os.path.join(experiment_conf_dir, 'config')
    conf_map = {}
    conf_map['working_dir'] = '"' + working_dir + '"'
    conf_map['experiment_id'] = '"' + prefix + '"'
    conf_map['scan'] = '"' + scan + '"'
    if specfile is not None:
        conf_map['specfile'] = '"' + specfile + '"'
    temp_file = os.path.join(experiment_conf_dir, 'temp')
    with open(temp_file, 'a') as f:
        for key in conf_map:
            value = conf_map[key]
            if len(value) > 0:
                f.write(key + ' = ' + conf_map[key] + '\n')
    f.close()
    if not ver.ver_config(temp_file):
        print('please check the entered parameters. Cannot save this format')
    else:
        shutil.copy(temp_file, experiment_main_config)
    os.remove(temp_file)

    copy_conf(conf_dir, experiment_conf_dir)
    if 'copy_prep' in kwargs:
        copy_prep = kwargs['copy_prep']
    if copy_prep:
        # use abspath to get rid of trailing dir sep if it is there
        other_exp_dir = os.path.split(os.path.abspath(conf_dir))[0]
        new_exp_dir = os.path.split(os.path.abspath(experiment_conf_dir))[0]

        # get case of single scan or summed
        prep_dir_list = glob.glob(os.path.join(other_exp_dir, 'prep'),
                                  recursive=True)
        for dir in prep_dir_list:
            shutil.copytree(dir, os.path.join(new_exp_dir, 'prep'))

            # get case of split scans
        prep_dir_list = glob.glob(os.path.join(other_exp_dir, "scan*/prep"),
                                  recursive=True)
        for dir in prep_dir_list:
            scandir = os.path.basename(os.path.split(dir)[0])
            shutil.copytree(dir, os.path.join(new_exp_dir, *(scandir, 'prep')))
    return experiment_dir
コード例 #29
0
ファイル: online_pnl_plot.py プロジェクト: yssource/quant
def CfgSetting(path):
    f = open(path)
    setting = cfg.Config(f.read())
    f.close()
    return 'holding time:' + str(setting.lookup('strategy')[0].max_holding_sec)
コード例 #30
0
ファイル: backend.py プロジェクト: ardnet/genesis
 def __init__(self):
     self.config_file = self.app.get_config(self).cfg_file
     self.service_mgr = self.app.get_backend(apis.services.IServiceManager)
     self.config = pylibconfig2.Config("")