コード例 #1
0
def dispatch(request):
    log = logger.logger("wavemoldb.api")

    if request.method != "POST":
        log.info("Invalid import request from " + str(request.get_host()) +
                 " : not POST request")
        return http.HttpResponseBadRequest("Accepting POST")
    try:
        xml = request.POST["xml"]
    except:
        log.info("Invalid import request from " + str(request.get_host()) +
                 " : xml parameter missing")
        return http.HttpResponseBadRequest("xml parameter missing")

    g = rdflib.ConjunctiveGraph()
    g.parse(StringIO.StringIO(xml))

    fs = filestorage.FileStorage("importer",
                                 web_accessible=False,
                                 settings=settings.filestorage_settings)
    identifier = str(uuid.uuid4())
    path = fs.path(identifier + ".rdf")
    f = open(path, "w")
    f.write(g.serialize())
    f.close()

    q = models.QueuedTask(type="import",
                          parameters=identifier,
                          status="QUEUED")
    q.save()
    log.info("Accepted submission " + str(identifier) + " from " +
             str(request.get_host()))

    return http.HttpResponse(status=202)
コード例 #2
0
    def get_uuid(self):
        """ We look to see if a uuid file exists
            If so, we use that to know where to work
            If not we produce one so future runs
            have a definitive id to use

        """

        uuid_file_name = os.path.join(self.datadir, 'uuid')
        if os.path.exists(uuid_file_name):
            uuid_file = open(uuid_file_name,'r')
            uuid = uuid_file.readline().strip()
            uuid_file.close()
        else:
            uuid = uuid4()
            uuid_file = open(uuid_file_name,'w')
            uuid_file.write(str(uuid))
            uuid_file.close()
        return uuid
コード例 #3
0
    def get_uuid(self):
        """ We look to see if a uuid file exists
            If so, we use that to know where to work
            If not we produce one so future runs
            have a definitive id to use

        """

        uuid_file_name = os.path.join(self.datadir, 'uuid')
        if os.path.exists(uuid_file_name):
            uuid_file = open(uuid_file_name, 'r')
            uuid = uuid_file.readline().strip()
            uuid_file.close()
        else:
            uuid = uuid4()
            uuid_file = open(uuid_file_name, 'w')
            uuid_file.write(str(uuid))
            uuid_file.close()
        return uuid
コード例 #4
0
def _generate_id(submission):
    storage = filestorage.ResourceStorage(submission, web_accessible=False, settings=settings.filestorage_settings)
    f=file(storage.path("system","uuid"), "w")
    f.write(str(uuid.uuid4()))
    f.close()
    return _get_id(submission)
コード例 #5
0
ファイル: __init__.py プロジェクト: vbehar/pyquizz
def generate_uuid():
    return str(uuid.uuid4())