def __init__(self): log_handler = logging.FileHandler("fitbit_harvester.log", "a") log_handler.setLevel(logging.DEBUG) formatter = logging.Formatter( '%(name)s\t%(levelname)s\t%(asctime)s\t%(message)s') log_handler.setFormatter(formatter) self.logger = logging.getLogger() self.logger.setLevel(logging.DEBUG) for handler in self.logger.handlers: # remove default handler self.logger.removeHandler(handler) self.logger.addHandler(log_handler) data_root = keyring.util.platform_.data_root() if not os.path.exists(data_root): os.mkdir(data_root) keyring.set_keyring(PlaintextKeyring()) self.parser = argparse.ArgumentParser(prog="run") self.parser.add_argument( '--config', help="Set config (input requires JSON) and exit.") self.parser.add_argument( '--get-config', action="store_true", help="Output current config as JSON and exit.") self.parser.add_argument('--server', help="The server URL to connect to.") # init fitbit consumer_key = "9cc7928d03fa4e1a92eda0d01ede2297" consumer_secret = "340ea36a974e47738a335c0cccfe1fcf" self.fitbit = Fitbit(consumer_key, consumer_secret) self.fitbit_intraday = None self.box_version = 0 self.config_overwrite = False self.config_start = self.today() self.config_box = None self.config_indx_user = None self.config_indx_pass = None self.config_fetched_days = [] self.config_zeros_from = self.today() self.harvester_id = "fitbit_harvester" self.steps_ts_id = "fitbit_steps_ts" self.calories_ts_id = "fitbit_calories_ts" self.distance_ts_id = "fitbit_distance_ts" self.floors_ts_id = "fitbit_floors_ts" self.elevation_ts_id = "fitbit_elevation_ts" self.ts_count = 0 self.ts_error = None
def __init__(self): log_handler = logging.FileHandler("nikeplus_harvester.log", "a") log_handler.setLevel(logging.DEBUG) formatter = logging.Formatter('%(name)s\t%(levelname)s\t%(asctime)s\t%(message)s') log_handler.setFormatter(formatter) self.logger = logging.getLogger() self.logger.setLevel(logging.DEBUG) for handler in self.logger.handlers: self.logger.removeHandler(handler) self.logger.addHandler(log_handler) data_root = keyring.util.platform_.data_root() if not os.path.exists(data_root): os.mkdir(data_root) keyring.set_keyring(PlaintextKeyring()) self.parser = argparse.ArgumentParser(prog="run") self.parser.add_argument('--config', help="Set config (input requires JSON) and exit.") self.parser.add_argument('--get-config', action="store_true", help="Output current config as JSON and exit.") self.parser.add_argument('--server', help="The server URL to connect to.") self.nike = NikePlus() self.box_version = 0 self.harvester_id = "nikeplus_harvester" self.fuel_ts_id = "nikeplus_fuel_ts" self.calories_ts_id = "nikeplus_calories_ts" self.steps_ts_id = "nikeplus_steps_ts" self.stars_ts_id = "nikeplus_stars_ts" self.ts_ids_by_type = {'FUEL':self.fuel_ts_id, 'CALORIES':self.calories_ts_id, 'STEPS':self.steps_ts_id, 'STARS':self.stars_ts_id } self.ts_count = 0 self.ts_error = None self.rdf_types = { 'FUEL':'http://sociam.org/ontology/health/NikeFuel', 'CALORIES':'http://sociam.org/ontology/health/CaloriesBurned', 'STEPS':'http://sociam.org/ontology/health/StepCount', 'STARS':'http://sociam.org/ontology/health/Intensity' } self.zeros = self.today() self.new_zeros = self.today() self.retrieved = self.today() self.config_box = None self.config_indx_user = None self.config_indx_pass = None self.config_max_date = datetime(2013, 7, 1)
def init(): # some platforms have no data root. we can take care of them now. data_root = keyring.util.platform_.data_root() if not os.path.exists(data_root): os.mkdir(data_root) keyring.set_keyring(PlaintextKeyring())