コード例 #1
0
    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
コード例 #2
0
    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
コード例 #3
0
 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()
コード例 #4
0
    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)
コード例 #5
0
ファイル: enrichers.py プロジェクト: Lin1205/DOM_example2
    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']
コード例 #6
0
ファイル: run.py プロジェクト: lok-18/Pytorch_Image_Fusion
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)
コード例 #7
0
 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]
コード例 #8
0
                       '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,
コード例 #9
0
def one_step(path=''):
    load_config(path)
    init()
    setup()
    deploy()
コード例 #10
0
def deploy(path=''):
    load_config(path)
    deploy_project()
コード例 #11
0
def setup(path=''):
    load_config(path)
    setup_project()
    setup_web_app()
コード例 #12
0
def init(path=''):
    load_config(path)
    init_machine()
コード例 #13
0
def config(path=''):
    load_config(path)
    log('load_config:' + str(env['load_config']) + " in the task->'config()'")
コード例 #14
0
def create_super_user(path=''):
    load_config(path)
    with cd(env.django_project_root):
        virtenvsudo('python manage.py createsuperuser')
コード例 #15
0
    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())