def share(self, project_id, new_contributor): """Allow another person to contribute to your project.""" msg = client.serialize("share", project_id, new_contributor) reply = self.__client.send(msg) if DEBUG: print(reply) return server.deserialize(reply)
def unsubscribe(self, cookie): """Unsubscribe to updates to a project.""" msg = client.serialize("unsubscribe", cookie) reply = self.__client.send(msg) if DEBUG: print(reply) return server.deserialize(reply)
def register(self, uname, pword, email): """Attempt to register a new user's username password email.""" msg = client.serialize("register", uname, pword, email) reply = self.__client.send(msg) if DEBUG: print(reply) return server.deserialize(reply)
def login(self, uname, pword): """Attempt to login with a username and password.""" msg = client.serialize("login", uname, pword) reply = self.__client.send(msg) # status, reason = reply if DEBUG: print(reply) return server.deserialize(reply)
def retrieve_project_listings_for(self, uname): """ list-projects username Get a list of all projects this user is a collaborator on """ msg = client.serialize("list_projects", uname) reply = self.__client.send(msg) return server.deserialize(reply)
def subscribe(self, uname, project_id): """Subscribe to updates to a project.""" msg = client.serialize("subscribe", uname, project_id) reply = self.__client.send(msg) # print(reply) j = json.loads(reply) if DEBUG: print(j[1][0]) return server.deserialize(reply)
def __version_handshake(self): """Perform a version handshake with the remote Composte server.""" msg = client.serialize("handshake", misc.get_version()) reply = self.__client.send(msg) if DEBUG: print(reply) reply = server.deserialize(reply) if reply[0] == "fail": status, reason = reply version = reason[0] raise GenericError(version)
def update(self, pid, fname, args, partIndex=None, offset=None): """ update project-id update-type args partIndex = None offset = None Send a music related update for the remote backend to process. args is a tuple of arguments """ args = json.dumps(args) msg = client.serialize("update", pid, fname, args, partIndex, offset) reply = self.__client.send(msg) if DEBUG: print(reply) return server.deserialize(reply)
def get_project(self, project_id): """Given a uuid, get the project to work on.""" msg = client.serialize("get_project", project_id) reply = server.deserialize(self.__client.send(msg)) if DEBUG: print(reply) status, ret = reply if status == "ok": print(type(ret)) realProj = json.loads(ret[0]) self.__project = util.composteProject.deserializeProject(realProj) return reply
def create_project(self, uname, pname, metadata): """ create-project username project-name metadata Attempt to create a project. Metdata must have the form of a json object, eg "{ "owner": username }" """ if type(metadata) == str: metadata = json.loads(metadata) metadata["owner"] = uname metadata["name"] = pname metadata = json.dumps(metadata) msg = client.serialize("create_project", uname, pname, metadata) reply = self.__client.send(msg) if DEBUG: print(reply) try: return server.deserialize(reply) except: print(reply) return ("fail", "Mangled reply")