Ejemplo n.º 1
0
 def on_post(self, req, resp, dataset, hexsha):
     """Run validation for a given commit"""
     if dataset and hexsha:
         # Record if this was done on behalf of a user
         name, email = get_user_info(req)
         media_dict = {}
         if name and email:
             media_dict['name'] = name
             media_dict['email'] = email
         try:
             dataset_path = self.store.get_dataset_path(dataset)
             # Run the validator but don't block on the request
             validate_dataset(dataset,
                              dataset_path,
                              hexsha,
                              req.cookies,
                              user=name)
             resp.status = falcon.HTTP_OK
         except:
             resp.status = falcon.HTTP_INTERNAL_SERVER_ERROR
     else:
         resp.media = {
             'error': 'Missing or malformed dataset parameter in request.'
         }
         resp.status = falcon.HTTP_UNPROCESSABLE_ENTITY
Ejemplo n.º 2
0
def update_head(ds, dataset_id, cookies=None):
    """Pass HEAD commit references back to OpenNeuro"""
    ref = ds.repo.get_hexsha()
    # We may want to detect if we need to run validation here?
    validate_dataset(dataset_id, ds.path, ref)
    r = requests.post(url=GRAPHQL_ENDPOINT,
                      json=draft_revision_mutation(dataset_id, ref), cookies=cookies)
    if r.status_code != 200:
        raise Exception(r.text)
Ejemplo n.º 3
0
def commit_files(store, dataset, files, name=None, email=None, cookies=None):
    """
    Commit a list of files with the email and name provided.

    Returns the commit hash generated.
    """
    ds = store.get_dataset(dataset)
    with CommitInfo(ds, name, email):
        if files:
            for filename in files:
                ds.save(filename)
        else:
            # If no list of paths, add all untracked files
            ds.save('.')
    ref = ds.repo.get_hexsha()
    # Run the validator but don't block on the request
    validate_dataset(dataset, ds.path, ref, cookies)
    return ref