def initiate(content=None):
    analysis_entry = Revision(id="131231",
                              pageid=1213,
                              )
    analysis_entry.put()

    g = GoogleConnect()

    g.write_to_bucket(bucket_name="revision_original",
                      file_to_write="testfile.txt",
                      content=content)

    read_text = g.read_from_bucket(bucket_name="revision_original",
                      file_to_write="testfile.txt")

    print read_text
    return read_text
示例#2
0
def initiate(content=None):
    analysis_entry = Revision(
        id="131231",
        pageid=1213,
    )
    analysis_entry.put()

    g = GoogleConnect()

    g.write_to_bucket(bucket_name="revision_original",
                      file_to_write="testfile.txt",
                      content=content)

    read_text = g.read_from_bucket(bucket_name="revision_original",
                                   file_to_write="testfile.txt")

    print read_text
    return read_text
示例#3
0
def _put_revisions_in_storage(pageid=None,
                              bucket_name=None,
                              folder_name=None,
                              revisions=None,
                              storage_meta=None,
                              ndb_entry=None):
    """

    :param revisions:
    :return:
    """
    g = GoogleConnect()

    for i, v in enumerate(revisions):
        revid = v['revid']
        filename = str(revid) + ".json"
        try:
            g.write_to_bucket(bucket_name=bucket_name,
                              folder_name=folder_name,
                              file_to_write=filename,
                              storage_meta=storage_meta,
                              content=json.dumps(obj=v))
            # print ("Written to bucket")

        except Exception, e:
            print "Exception while writing to bucket is: {}".format(str(e))
            #return e
            raise HTTP(500)

        try:
            # Make meta-data entry into NDB

            entry = _write_to_ndb(model=ndb_entry, pageid=pageid, revision=v)

        except Exception, er:
            print "Error is {}".format(str(er))
            # print er
            #return er
            raise HTTP(500)
def _put_revisions_in_storage(
    pageid=None, bucket_name=None, folder_name=None, revisions=None, storage_meta=None, ndb_entry=None
):
    """

    :param revisions:
    :return:
    """
    g = GoogleConnect()

    for i, v in enumerate(revisions):
        revid = v["revid"]
        filename = str(revid) + ".json"
        try:
            g.write_to_bucket(
                bucket_name=bucket_name,
                folder_name=folder_name,
                file_to_write=filename,
                storage_meta=storage_meta,
                content=json.dumps(obj=v),
            )
            # print ("Written to bucket")

        except Exception, e:
            print "Exception while writing to bucket is: {}".format(str(e))
            # return e
            raise HTTP(500)

        try:
            # Make meta-data entry into NDB

            entry = _write_to_ndb(model=ndb_entry, pageid=pageid, revision=v)

        except Exception, er:
            print "Error is {}".format(str(er))
            # print er
            # return er
            raise HTTP(500)