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)