def process_file(self, data, callback=lambda:None): filename = os.path.join(self.destination_dir, data['filename']) if not os.path.exists(filename): callback() return if not os.path.exists(self.destination_dir): os.mkdir(self.destination_dir) # FIXME - don't use external tools! from subprocess import getoutput tar_output = getoutput('env LANG=C tar -xvf "%s" -C "%s"' % (filename, self.destination_dir)) bundlepath = os.path.join(self.destination_dir, tar_output.strip().split("\n", 1)[0]) if not os.path.exists(bundlepath): raise IOError(bundlepath) # make sure pedalboard is valid name = get_pedalboard_name(bundlepath) SESSION.load_pedalboard(bundlepath, name) os.remove(filename) callback()
def process_file(self, data, callback=lambda: None): filename = os.path.join(self.destination_dir, data['filename']) if not os.path.exists(filename): callback() return if not os.path.exists(self.destination_dir): os.mkdir(self.destination_dir) # FIXME - don't use external tools! from subprocess import getoutput tar_output = getoutput('env LANG=C tar -xvf "%s" -C "%s"' % (filename, self.destination_dir)) bundlepath = os.path.join(self.destination_dir, tar_output.strip().split("\n", 1)[0]) if not os.path.exists(bundlepath): raise IOError(bundlepath) # make sure pedalboard is valid name = get_pedalboard_name(bundlepath) SESSION.load_pedalboard(bundlepath, name) os.remove(filename) callback()
def post(self): bundlepath = self.get_argument("bundlepath") try: name = get_pedalboard_name(bundlepath) except Exception as e: self.set_header('Content-Type', 'application/json') self.write(json.dumps({ 'ok': False, 'error': str(e).split(") - ",1)[-1] })) self.finish() return SESSION.load_pedalboard(bundlepath, name) self.set_header('Content-Type', 'application/json') self.write(json.dumps({ 'ok': True, 'name': name })) self.finish()
def post(self): bundlepath = self.get_argument("bundlepath") try: name = get_pedalboard_name(bundlepath) except Exception as e: self.set_header('Content-Type', 'application/json') self.write( json.dumps({ 'ok': False, 'error': str(e).split(") - ", 1)[-1] })) self.finish() return SESSION.load_pedalboard(bundlepath, name) self.set_header('Content-Type', 'application/json') self.write(json.dumps({'ok': True, 'name': name})) self.finish()
def post(self): bundlepath = os.path.abspath(self.get_argument("bundlepath")) try: isDefault = bool(int(self.get_argument("isDefault"))) except: isDefault = False if os.path.exists(bundlepath): name = SESSION.load_pedalboard(bundlepath, isDefault) else: name = None self.write({'ok': name is not None, 'name': name or ""})