def load_task_common_config(self): config_file = os.path.join( TASK_CONFIG_ROOT_PATH, self.app_name(), 'common.yaml') if os.path.isfile(config_file): return util.load_yaml(config_file) else: return {}
def load_config(self): common_config = util.deepmerge( self.load_common_config(), self.load_task_common_config()) task_config = util.load_yaml(os.path.join( TASK_CONFIG_ROOT_PATH, self.app_name(), '{}.yaml'.format(self.__class__.__name__))) return util.deepmerge(task_config, common_config)
def __init__(self, google_creds, mongo_config): self.config = util.load_yaml(CONFIG_PATH) self.sheet_service = GoogleSheet(google_creds) self.load_events() self.load_schedules() conn = MongoConnection(mongo_config) self.session_store = SessionStore(conn) self.presenter_store = PresenterStore(conn)
def get_member_info(): config = util.load_yaml(COMMON_CONFIG_PATH) conn = MongoConnection(config['mongo']) store = MemberStore(conn) members = store.find_all({}, max_cnt=1000) with open('/root/members.csv', 'w') as f: fieldnames = ['name', 'email', 'card'] writer = csv.DictWriter(f, delimiter=',', fieldnames=fieldnames) writer.writeheader() for member in members: row = { 'name': member.get('name', ''), 'email': member.get('email', ''), 'card': member.get('membership_card', {}).get('baseUrl', '') } writer.writerow(row)
def load_common_config(self): common_config_file = os.path.join(CONFIG_ROOT_PATH, 'common.yaml') return util.load_yaml(common_config_file)
def member_card_test(): config = util.load_yaml(COMMON_CONFIG_PATH) imgur = Imgur(config['imgur']['creds_file']) photos = imgur.get_photos('TTA1Bp4') imgur.upload_photos(photos, 'XaBxokL') pprint(photos[0].__dict__)
def member_sync(): config = util.load_yaml(COMMON_CONFIG_PATH) MemberSync(google_creds(config), config['imgur'], config['mongo']).sync_membership_card()
def event_poster(): config = util.load_yaml(COMMON_CONFIG_PATH) WhitepaperJournalEventPoster(google_creds(config)).process(1550875924)
def test_photo(): config = util.load_yaml(COMMON_CONFIG_PATH) service = GooglePhoto(config['google']) filepath = "/tmp/abc_apps/whitepaper_journal/event_poster/output/blockspace_20190215.jpg" service.create_item(POST_ALBUM_ID, filepath, "poster for test")
def test_mongo(): config = util.load_yaml(CONFIG_PATH) common_config = util.load_yaml(COMMON_CONFIG_PATH) config.update(common_config) service = Service(config['mongo']) print(service.get_recent_sessions())
def config(): config = util.load_yaml(CONFIG_PATH) common_config = util.load_yaml(COMMON_CONFIG_PATH) config.update(common_config) return config
def get_api_key(self): meetup_config = util.load_yaml(self.config['meetup']['api_key']) return meetup_config['api_key']