本文整理汇总了Python中pychron.paths.paths.build函数的典型用法代码示例。如果您正苦于以下问题:Python build函数的具体用法?Python build怎么用?Python build使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了build函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run():
import argparse
import os
paths.build(os.getenv('PYCHRON_ROOT'))
logging_setup('furnace_firmware', use_archiver=False)
parser = argparse.ArgumentParser(description='Run NMGRL Furnace Firmware')
# parser.add_argument('--host',
# type=str,
# default='127.0.0.1',
# help='host')
parser.add_argument('--port',
type=int,
default=4567,
help='TCP port to listen')
# parser.add_argument('--debug',
# action='store_true',
# default=False,
# help='run in debug mode')
fm = Firmware()
fm.bootstrap(**vars(parser.parse_args()))
示例2: main
def main():
from pychron.paths import paths
paths.build('_dev')
from pychron.core.helpers.logger_setup import logging_setup
from pychron.experiment.automated_run.spec import AutomatedRunSpec
logging_setup('dvcdb')
from pychron.dvc.dvc_database import DVCDatabase
from itertools import groupby
db = DVCDatabase(kind='mysql', host='localhost', username='root', name='pychronmeta', password='Argon')
db.connect()
identifiers = ['63290', '63291']
runs = [AutomatedRunSpec(identifier='63290', repository_identifier='Cather_McIntoshd')]
cr = ConflictResolver()
experiments = {}
cr.available_ids = db.get_repository_identifiers()
eas = db.get_associated_repositories(identifiers)
for idn, exps in groupby(eas, key=lambda x: x[1]):
experiments[idn] = [e[0] for e in exps]
conflicts = []
for ai in runs:
identifier = ai.identifier
es = experiments[identifier]
if ai.repository_identifier not in es:
conflicts.append((ai, es))
if conflicts:
cr.add_conflicts('Foo', conflicts)
if cr.conflicts:
info = cr.edit_traits(kind='livemodal')
if info.result:
cr.apply()
示例3: test_save_persister
def test_save_persister():
paths.build('_dev')
dvc = DVC(bind=False)
dvc.db.connect()
per = DVCPersister(dvc=dvc)
run_spec = AutomatedRunSpec()
run_spec.labnumber = '10001'
run_spec.project = 'Test'
arar = ArArAge()
arar.isotopes['Ar40'] = Isotope(xs=[1, 2, 3], ys=[1, 2, 3],
name='Ar40', detector='H1')
sd = {}
dd = {'H1': 100}
gd = {'H1': 1.021}
per_spec = PersistenceSpec(run_spec=run_spec,
arar_age=arar,
spec_dict=sd,
defl_dict=dd,
gains=gd,
positions=[1, ],
experiment_queue_name='testexp.txt',
measurement_name='jan_unknown.py',
extraction_name='foo.py')
per.per_spec_save(per_spec)
示例4: main
def main():
paths.build('_dev')
global log
if not log:
logging_setup('heapy')
log = True
return run()
示例5: initialize_version
def initialize_version(appname, debug):
root = os.path.dirname(__file__)
if not debug:
add_eggs(root)
else:
build_sys_path()
# can now use pychron.
from pychron.paths import paths
# paths.bundle_root = root
# if '-' in setup_ver:
# setup_ver = setup_ver.split('-')[0]
from pychron.envisage.user_login import get_user
user = get_user()
if not user:
logger.info('user login failed')
os._exit(0)
if appname.startswith('py'):
appname = appname[2:]
pref_path = os.path.join(paths.base, '.enthought',
'pychron.{}.application.{}'.format(appname, user),
'preferences.ini')
from ConfigParser import ConfigParser
cp = ConfigParser()
cp.read(pref_path)
try:
proot = cp.get('pychron.general', 'root_dir')
except BaseException:
proot = '/Users/ross/Pychron'
paths.build(proot)
# build globals
build_globals(debug)
from pychron.core.helpers.logger_setup import logging_setup
from pychron.paths import build_directories
# build directories
build_directories()
# setup logging. set a basename for log files and logging level
logging_setup('pychron', level='DEBUG')
return user
示例6: get_db
def get_db():
conn = dict(host=os.environ.get('ARGONSERVER_HOST'),
username='jross', # os.environ.get('ARGONSERVER_DB_USER'),
password=os.environ.get('ARGONSERVER_DB_PWD'),
kind='mysql')
paths.build('~/PychronDev')
meta_name = 'NMGRLMetaData'
dvc = DVC(bind=False,
organization='NMGRLData',
meta_repo_name=meta_name)
paths.meta_root = os.path.join(paths.dvc_dir, dvc.meta_repo_name)
dvc.db.trait_set(**conn)
if not dvc.initialize():
warning(None, 'Failed to initialize DVC')
return
dvc.meta_repo.smart_pull()
return dvc
示例7: build_version
def build_version(ver=None, setup_ver=None, debug=False):
if ver is None:
ver = ""
if setup_ver is None:
setup_ver = ""
root = os.path.dirname(__file__)
if not debug:
add_eggs(root)
else:
build_sys_path(ver, root)
# can now use pychron.
from pychron.paths import paths
paths.bundle_root = root
if "-" in setup_ver:
setup_ver = setup_ver.split("-")[0]
paths.build(setup_ver)
# build globals
build_globals(debug)
示例8: closed
def closed(self, info, ok):
if ok:
info.object.save()
class SpectrometerParametersView(HasTraits):
model = Instance("SpectrometerParameters")
def trait_context(self):
return {"object": self.model}
def traits_view(self):
v = View(
UItem("groups", style="custom", editor=ListEditor(mutable=False, use_notebook=True, page_name=".name")),
buttons=["OK", "Cancel"],
handler=SHandler,
title="Spectrometer Settings",
kind="livemodal",
)
return v
if __name__ == "__main__":
paths.build("_dev")
s = SpectrometerParameters()
s.load()
v = SpectrometerParametersView(model=s)
v.configure_traits()
# ============= EOF =============================================
示例9: suite
def suite():
# set env. variables
os.environ['MassSpecDBVersion'] = '16'
from pychron.paths import paths
paths.build('_dev')
if use_logger:
from pychron.core.helpers.logger_setup import logging_setup
logging_setup('unittests')
# Canvas
from pychron.canvas.canvas2D.tests.calibration_item import CalibrationObjectTestCase
# Core
from pychron.core.tests.spell_correct import SpellCorrectTestCase
from pychron.core.tests.filtering_tests import FilteringTestCase
from pychron.core.stats.tests.peak_detection_test import MultiPeakDetectionTestCase
from pychron.core.helpers.tests.floatfmt import FloatfmtTestCase
from pychron.core.helpers.tests.strtools import CamelCaseTestCase
from pychron.core.xml.tests.xml_parser import XMLParserTestCase
from pychron.core.regression.tests.regression import OLSRegressionTest, MeanRegressionTest, \
FilterOLSRegressionTest, OLSRegressionTest2, TruncateRegressionTest, ExpoRegressionTest, ExpoRegressionTest2
# DataMapper
from pychron.data_mapper.tests.usgs_vsc_file_source import USGSVSCFileSourceUnittest, \
USGSVSCIrradiationSourceUnittest
from pychron.data_mapper.tests.nu_file_source import NuFileSourceUnittest
from pychron.data_mapper.tests.nmgrl_legacy_source import NMGRLLegacySourceUnittest
# Experiment
from pychron.experiment.tests.repository_identifier import ExperimentIdentifierTestCase
from pychron.experiment.tests.peak_hop_parse import PeakHopYamlCase1
from pychron.experiment.tests.peak_hop_parse import PeakHopYamlCase2
from pychron.experiment.tests.backup import BackupTestCase
from pychron.experiment.tests.peak_hop_parse import PeakHopTxtCase
from pychron.experiment.tests.duration_tracker import DurationTrackerTestCase
from pychron.experiment.tests.frequency_test import FrequencyTestCase, FrequencyTemplateTestCase
from pychron.experiment.tests.position_regex_test import XYTestCase
from pychron.experiment.tests.renumber_aliquot_test import RenumberAliquotTestCase
from pychron.experiment.tests.conditionals import ConditionalsTestCase, ParseConditionalsTestCase
from pychron.experiment.tests.identifier import IdentifierTestCase
from pychron.experiment.tests.comment_template import CommentTemplaterTestCase
# ExternalPipette
from pychron.external_pipette.tests.external_pipette import ExternalPipetteTestCase
# Processing
from pychron.processing.tests.plateau import PlateauTestCase
from pychron.processing.tests.ratio import RatioTestCase
from pychron.processing.tests.age_converter import AgeConverterTestCase
# Pyscripts
from pychron.pyscripts.tests.extraction_script import WaitForTestCase
from pychron.pyscripts.tests.measurement_pyscript import InterpolationTestCase, DocstrContextTestCase
# Spectrometer
from pychron.spectrometer.tests.mftable import MFTableTestCase, DiscreteMFTableTestCase
from pychron.spectrometer.tests.integration_time import IntegrationTimeTestCase
from pychron.stage.tests.stage_map import StageMapTestCase, TransformTestCase
loader = unittest.TestLoader()
suite = unittest.TestSuite()
tests = (
# Canvas
CalibrationObjectTestCase,
# Core
SpellCorrectTestCase,
FilteringTestCase,
MultiPeakDetectionTestCase,
FloatfmtTestCase,
CamelCaseTestCase,
RatioTestCase,
XMLParserTestCase,
OLSRegressionTest,
MeanRegressionTest,
ExpoRegressionTest,
ExpoRegressionTest2,
FilterOLSRegressionTest,
OLSRegressionTest2,
TruncateRegressionTest,
# DataMapper
USGSVSCFileSourceUnittest,
USGSVSCIrradiationSourceUnittest,
NuFileSourceUnittest,
NMGRLLegacySourceUnittest,
# Experiment
ExperimentIdentifierTestCase,
PeakHopYamlCase1,
PeakHopYamlCase2,
BackupTestCase,
PeakHopTxtCase,
DurationTrackerTestCase,
FrequencyTestCase,
FrequencyTemplateTestCase,
#.........这里部分代码省略.........
示例10: get_powermaps
# ==============================================================================
# getters
# ==============================================================================
def get_powermaps(self, **kw):
return self._retrieve_items(PowerMapTable)
# return self._get_items(PowerMapTable, globals(), **kw)
# =============================================================================
# adder
# =============================================================================
def add_powermap(self, **kw):
b = PowerMapTable(**kw)
self._add_item(b)
# b = self._add_timestamped_item(PowerMapTable, **kw)
return b
if __name__ == '__main__':
paths.build('_diode')
db = PowerMapAdapter(name=paths.powermap_db,
kind='sqlite')
db.connect()
dbs = PowerMapSelector(db=db)
dbs.load_recent()
dbs.configure_traits()
# ============= EOF =============================================
示例11: setUp
def setUp(self):
paths.build('_dt')
self.dt = AutomatedRunDurationTracker()
示例12: _start_recording
def _start_recording(self):
self._recording = True
self.record_data_manager = dm = self._record_data_manager_factory()
dm.new_frame(directory=paths.furnace_scans_dir)
dm.write_to_frame(('time', 'temperature', 'output'))
self._start_time = time.time()
def _stop_recording(self):
self._recording = False
def traits_view(self):
v = View(VGroup(Item('setpoint'), Item('temperature_readback', style='readonly'),
HGroup(UItem('start_record_button'), UItem('stop_record_button'),
Item('recording_period', label='Period (m)')),
UItem('graph', style='custom')),
title='Standalone Furnace Controller')
return v
if __name__ == '__main__':
from pychron.core.helpers.logger_setup import logging_setup
paths.build(os.path.join(os.path.expanduser('~'), 'PychronFurnace'))
logging_setup('furnace_record', use_archiver=False)
f = SimpleFurnace()
f.bootstrap()
f.controller.bootstrap()
f.start_update()
f.configure_traits()
示例13: initialize_version
def initialize_version(appname, debug):
root = os.path.dirname(__file__)
if not debug:
add_eggs(root)
else:
build_sys_path()
# from pychron.environment.util import get_environment
# env = get_environment(appname)
from pychron.envisage.user_login import get_user
args = get_user()
if args is None:
return False
else:
user, env = args
# if not env:
# logger.info('no environment available')
# from pyface.directory_dialog import DirectoryDialog
#
# information(None, 'An "environment" directory is not set in Preferences/General. Please select a valid '
# 'directory')
# dlg = DirectoryDialog(action='open', default_directory=os.path.expanduser('~'))
# result = dlg.open()
# if result == OK:
# env = str(dlg.path)
# from pychron.environment.util import set_environment
# set_environment(appname, env)
# else:
if not env:
return False
set_application_home(appname, env)
from pychron.paths import paths
logger.debug('using Pychron environment: {}'.format(env))
paths.build(env)
from configparser import ConfigParser, NoSectionError
cp = ConfigParser()
pref_path = os.path.join(ETSConfig.application_home, 'preferences.ini')
cp.read(pref_path)
try:
cp.set('pychron.general', 'environment', env)
except NoSectionError:
cp.add_section('pychron.general')
cp.set('pychron.general', 'environment', env)
root = os.path.dirname(pref_path)
if not os.path.isdir(root):
os.mkdir(root)
with open(pref_path, 'w') as wfile:
cp.write(wfile)
# build globals
build_globals(user, debug)
from pychron.core.helpers.logger_setup import logging_setup
from pychron.paths import build_directories
# build directories
build_directories()
paths.write_defaults()
# setup logging. set a basename for log files and logging level
logging_setup('pychron', level='DEBUG')
from pychron.core.helpers.exception_helper import set_exception_handler
set_exception_handler()
return env
示例14: _measurement_script_default
kind='livemodal', buttons=['OK', 'Cancel'])
return v
def _measurement_script_default(self):
s = Script(label='measurement')
return s
def _extraction_script_default(self):
s = Script(label='extraction')
return s
if __name__ == '__main__':
from pychron.paths import paths
paths.build('~/PychronDev')
af = BulkRunFixer()
class Run:
extraction_script = 'Foo'
measurement_script = 'Bar'
analysis_type = 'unknown'
a = Run()
a.analysis_type = 'air'
b = Run()
b.analysis_type = 'blank'
c = Run()
runs = [a, b, c]
示例15: main1
def main1():
from random import random
# from pychron.paths import paths
paths.build('_dev')
# def add_runs(c, e):
# class Spec():
# def __init__(self, record_id):
# self.runid = record_id
# # self.mass_spectrometer = 'jan'
# # self.extract_device = 'LF'
# self.analysis_timestamp = datetime.now()
# self.state = choice(['Finished', 'Canceled', 'Failed'])
# self.analysis_type = "unknown"
# self.sample = "FC-2"
# self.extract_value = random() * 2
# self.extract_units = 'watts'
# self.duration = randint(100, 200)
# self.cleanup = randint(100, 200)
# self.position = randint(0, 100)
# self.comment = "Test comment"
# self.material = "sanidine"
# self.project = "Monitor"
# self.measurement_script = 'unknown400_180'
# self.extraction_script = 'sniffair_x1'
# self.post_measurement_script = 'pump_spectrometer'
# self.post_equilibration_script = 'pump_extraction_line'
#
# class Run():
# def __init__(self, *args, **kw):
# self.spec = Spec(*args, **kw)
#
# for i in range(6):
# c.add_run(Run('20016-{:02d}'.format(i + 1)), e)
#
# def add_experiment(c):
# class Exp():
# def __init__(self, name, user, status):
# self.name = name
# self.username = user
# spec = choice(('Jan','Obama'))
# self.spectrometer = spec
# self.mass_spectrometer = spec
# self.extract_device = choice(('Fusions CO2', 'Fusions Diode'))
# self.status = status
# self.starttime = datetime.now()
#
# e = Exp('Current Experiment', 'foobar', 'Running')
# c.add_experiment(e)
# return e
#
# def update_status(c):
# c.update_status(Error='Error big time')
# c.update_status(Message='This is a long message',
# ShortMessage='This is a short message')
def add_measurements(c):
for i in range(100):
c.add_measurement('AirPressure', 'pneumatics', random(), 'PSI')
c.add_measurement('Environmental', 'temperature', random() * 2 + 70,
'C')
c.add_measurement('Environmental', 'humidity', random() * 5 + 50,
'%')
time.sleep(1)
logging_setup('labspyclient', use_archiver=False)
# c = LabspyClient(bind=False, host='129.138.12.138', port=27017)
# c = MeteorLabspyClient(bind=False, host='localhost', port=3001)
# # update_state(c)
# for i in range(10):
# add_device(c)
# time.sleep(1)
clt = LabspyClient(bind=False)
clt.db.host = 'localhost'
clt.db.username = os.environ.get('DB_USER')
clt.db.password = os.environ.get('DB_PWD')
clt.db.name = 'labspy'
clt.test_connection()
# set status
# update_status(clt)
# measurements
add_measurements(clt)