def __init__(self, mode="F"): self._mode = mode config = load_config() self._sensor_type = config[ 'temp_sensor_type'] if 'temp_sensor_type' in config else None self.init_fail = True
def load_from_config(self): ''' loads the configuration for this unit ''' json_dic = load_config() self.controller = json_dic['controller'] self._red_pin = json_dic['red_pin'] if 'red_pin' in json_dic else None self._green_pin = json_dic['green_pin'] if 'green_pin' in json_dic else None self._blue_pin = json_dic['blue_pin'] if 'blue_pin' in json_dic else None
def __init__(self, mode="F", time_delay=20): super().__init__(mode) self._time_delay = time_delay self._sensor_type = 'DHT11' config = load_config() self.therm_pin = int(config['DHT11_pin']) self.init_fail = False self._last_called = time() self._temp = self._get_temp()
def set_thermometer(self, mode="F"): ''' sets up the thermometer ''' config = load_config() sensor_type = config[ 'temp_sensor_type'] if 'temp_sensor_type' in config else None # dht11 sensor if sensor_type.lower() == 'dht11' and bool(sensor_type): self.thermometer = DHT11(mode) # ds18b20 elif sensor_type.lower() == 'ds18b20' and bool(sensor_type): self.thermometer = DS18B20(mode) # all others else: self.thermometer = Thermometer(mode)
def __init__(self, latitude, longitude, radius=SEARCH_RADIUS, min_price=3, max_price=4, asset_id=None): self.base_url = 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?' self.latitude = latitude self.longitude = longitude self.radius = radius self.min_price = min_price self.max_price = max_price self.asset_id = asset_id # Retrieve Google API key from secrets file sec_config = load_config(SECRET_PATH) self.g_key = sec_config['google_key']
def runner(args): configs = load_config(args.config) project_configs = configs['PROJECT'] model_configs = configs['MODEL'] train_configs = configs['TRAIN'] test_configs = configs['TEST'] train_dataset_configs = configs['TRAIN_DATASET'] test_dataset_configs = configs['TEST_DATASET'] input_size = train_dataset_configs[ 'input_size'] if args.train else test_dataset_configs['input_size'] if train_dataset_configs['channels'] == 3: base_transforms = transforms.Compose([ transforms.Resize((input_size, input_size)), transforms.ToTensor() ]) # , # transforms.Normalize(mean=train_dataset_configs['mean'], std=train_dataset_configs['std'])]) elif train_dataset_configs['channels'] == 1: base_transforms = transforms.Compose([ transforms.Resize((input_size, input_size)), transforms.ToTensor() ]) # , # transforms.Normalize(mean=[sum(train_dataset_configs['mean']) / len(train_dataset_configs['mean'])], # std=[sum(train_dataset_configs['std']) / len(train_dataset_configs['std'])])]) train_datasets = Fusion_Datasets(train_dataset_configs, base_transforms) test_datasets = Fusion_Datasets(test_dataset_configs, base_transforms) model = eval(model_configs['model_name'])(model_configs) print('Model Para:', count_parameters(model)) if train_configs['resume'] != 'None': checkpoint = torch.load(train_configs['resume']) model.load_state_dict(checkpoint['model'].state_dict()) if args.train: train(model, train_datasets, test_datasets, configs) if args.test: test(model, test_datasets, configs, load_weight_path=True)
def __init__(self, key_name=None): self._key_name = key_name if key_name: json_dic = load_config() self._hashed_key = json_dic[key_name]
'session': session} if not first: time.sleep(3, 59) first = False run_cl_job(**kwargs_pass) print('Completed job {}'.format(hood)) # TODO: Add random wait if __name__ == "__main__": config = load_config(CONFIG_PATH) cl_config = config['scrapers']['craigslist'] # DB Setup. Create an engine to store data at specified path # By default SQLite expects one thread, but multithread is supported: # https://docs.sqlalchemy.org/en/13/dialects/sqlite.html engine = create_engine(config['db_path'], echo=True, connect_args={'check_same_thread': False}) Session = sessionmaker(bind=engine) session = Session() # Job Scheduler # scheduler = BackgroundScheduler() #executors=executors) sched = BlockingScheduler() kwargs_pass = {'config': cl_config,
def one_step(path=''): load_config(path) init() setup() deploy()
def deploy(path=''): load_config(path) deploy_project()
def setup(path=''): load_config(path) setup_project() setup_web_app()
def init(path=''): load_config(path) init_machine()
def config(path=''): load_config(path) log('load_config:' + str(env['load_config']) + " in the task->'config()'")
def create_super_user(path=''): load_config(path) with cd(env.django_project_root): virtenvsudo('python manage.py createsuperuser')
def test_util_load_scraper_config(self): """ Confirm that injested config contains 'db_path' """ config_in = cu.load_config(self.base_config_path) self.assertTrue('db_path' in config_in.keys())