Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b713d06b31
Fetching contributors…

Cannot retrieve contributors at this time

file 37 lines (31 sloc) 1.091 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at http://mozilla.org/MPL/2.0/.

import glob
import os
import requests

import stoneridge

class StoneRidgeUploader(object):
    """Takes the upload files created by the collator and uploads them to the
graph server
"""
    def __init__(self):
        self.url = stoneridge.get_config('upload', 'url')

    def run(self):
        file_pattern = os.path.join(stoneridge.outdir, 'upload_*.json')
        upload_files = glob.glob(file_pattern)
        if not upload_files:
            # Nothing to do, so forget it!
            return
        files = {os.path.basename(fname): open(fname, 'rb')
                 for fname in upload_files}
        requests.post(self.url, files=files)
        for f in files.values():
            f.close()

@stoneridge.main
def main():
    parser = stoneridge.ArgumentParser()
    args = parser.parse_args()

    uploader = StoneRidgeUploader()
    uploader.run()
Something went wrong with that request. Please try again.