def move(self, source, destination, zip=False): """ Performs a "move" of a file from a source to a destination @param source: URL describing the source of the move, or list of URLs. @type source: str or list @param destination: URL describing the destination of the move. @type destination: str @param zip: True to zip source to the destination. @type zip: bool @return: The status of the move @rtype: dict """ if source is None or destination is None: return response.error_rejected(response.REASON_MISSING_PARAMS_1S.format('source and destination must not be None')) source_valid, source_reason = self._validate_source_dict(source) if not source_valid: return response.error_rejected(source_reason) destination_valid, destination_reason = self._validate_destination(destination, zip) if not destination_valid: return response.error_rejected(destination_reason) move_job = MoveJob(source, destination, self._user_id, zip) self._move_jobs[move_job.id] = move_job self._executor.submit(fn=self._move_service.worker, move_job=move_job) return response.job_id_status(move_job)
def check_move_status(self, id=None): """ Checks the status of a "move" job that has been previously submitted @param id: The ID of the "move" job to check @type id: int @return: The status of the job """ if id is None: return response.error_rejected(response.REASON_MISSING_PARAMS_1S.format('id')) if not isinstance(id, str): return response.error_rejected(response.REASON_INVALID_PARAMS_1S.format('id must be a string')) job = self._move_jobs.get(id) if job is not None: ret = response.job_id_status(job) # Delete job if it is done if job.isDone(): del self._move_jobs[id] return ret else: return response.error_rejected(response.REASON_JOB_DOES_NOT_EXIST)