def upload(self): """Upload data""" trans = Transactions(self.connection) if not self.dryrun: trans.set_database(self.database) trans.set_timeLimit(trans.max_timeLimit()) trans.create() txid = trans.txid() mirror = True for name in os.listdir(self.path): if not name in ['content', 'metadata', 'ucontent', 'umetadata']: mirror = False if self.mirror and not mirror: raise RuntimeError("Path doesn't point to a mirror directory") try: if mirror: self._upload_mirror(trans) else: self._upload_directory(trans) except KeyboardInterrupt: if not self.dryrun: trans.rollback() except: if not self.dryrun: trans.rollback() raise else: if not self.dryrun: trans.commit()
def download(self): """Download data""" trans = Transactions(self.connection) if not self.dryrun: trans.set_database(self.database) trans.set_timeLimit(trans.max_timeLimit()) trans.create() try: if self.mirror: self._download_mirror(trans) else: self._download_directory(trans) except KeyboardInterrupt: if not self.dryrun: trans.rollback() except: if not self.dryrun: trans.rollback() raise else: if not self.dryrun: trans.commit()