def _get_game(slug):

    game = get_game_by_slug(slug)
    if not game:
        raise NotFound('No game with slug %s' % slug)

    return game
Beispiel #2
0
 def join(self, user):
     with self.lock:
         if self.deleted:
             raise NotFound('No data share with id "%s"' % self.datashare_id)
         if not self.joinable:
             raise Forbidden('Data share with id "%s" is not joinable' % self.datashare_id)
         if user.username not in self.users:
             self.users.append(user.username)
         self.write()
Beispiel #3
0
    def load(self):
        path = self.get_path()
        if not path_exists(path):
            raise NotFound('No data share with id "%s"' % self.datashare_id)
        try:
            with open(path, 'rt') as f:
                yaml_data = yaml.load(f)
                self.owner = yaml_data['owner']
                self.created = yaml_data['created']
                self.users = yaml_data['users']
                self.store = yaml_data['store']
                self.joinable = yaml_data['joinable']

        except (IOError, KeyError, yaml.YAMLError) as e:
            LOG.error('Failed loading datashare file "%s": %s' % (self.path, str(e)))
            raise
 def remove_all(cls, slug):
     game = get_game_by_slug(slug)
     if game is None:
         raise NotFound('No game with slug %s' % slug)
     DataShareList.get(game).remove_all()
     return {'ok': True}