def commit_post_data(webhook_request_json, branch='gh-pages'): """Commit a .html file in _posts/, a .json in data/, and append to the cumulative .json in data/.""" webhook = webhook_request_json # convenience account_id = webhook['account_id'] msg_id = webhook['message_data']['message_id'] msg = cio_requests.get( "https://api.context.io/2.0/accounts/{aid}/messages/{mid}".format( aid=account_id, mid=msg_id), params={'include_body': 1, 'body_type': 'text/plain'} ) # context.io responded with a list once? app.logger.debug('message response:') app.logger.debug(msg.json()) post = Post.from_cio_message(msg.json()) path_content_pairs = files_to_create(post) githubx.commit( repo='the-listserve-archive', file_descriptions=[file_description(*pair) for pair in path_content_pairs], commit_message="add post (%s)" % post.datestr(), branch=branch)
def commit_post_data(webhook_request_json, branch='gh-pages'): """Commit a .html file in _posts/, a .json in data/, and append to the cumulative .json in data/.""" webhook = webhook_request_json # convenience account_id = webhook['account_id'] msg_id = webhook['message_data']['message_id'] msg = cio_requests.get( "https://api.context.io/2.0/accounts/{aid}/messages/{mid}".format( aid=account_id, mid=msg_id), params={ 'include_body': 1, 'body_type': 'text/plain' }) # context.io responded with a list once? app.logger.debug('message response:') app.logger.debug(msg.json()) post = Post.from_cio_message(msg.json()) path_content_pairs = files_to_create(post) githubx.commit(repo='the-listserve-archive', file_descriptions=[ file_description(*pair) for pair in path_content_pairs ], commit_message="add post (%s)" % post.datestr(), branch=branch)
def test_commit_update_file(self): now = time.time() self.githubx.commit( repo='the-listserve-archive', file_descriptions=[ file_description(path='README', contents="Orphan branch used for GitHub api testing.\n%s" % now)], commit_message='update commit', branch='testing')
def test_commit_new_file(self): new_file = "file-%s" % time.time() self.githubx.commit( repo='the-listserve-archive', file_descriptions=[ file_description(path=new_file, contents='new file contents')], commit_message='new commit', branch='testing')