def findQuanty(): if sys.platform == "win32": executable = "Quanty.exe" localPath = resourceAbsolutePath( os.path.join("quanty", "bin", "win32")) elif sys.platform == "darwin": executable = "Quanty" localPath = resourceAbsolutePath( os.path.join("quanty", "bin", "darwin")) else: localPath = None executable = "Quanty" envPath = QStandardPaths.findExecutable(executable) if localPath is not None: localPath = QStandardPaths.findExecutable(executable, [localPath]) # Check if Quanty is in the paths defined in the $PATH. if envPath: path = envPath # Check if Quanty is bundled with Crispy. elif localPath is not None: path = localPath else: path = None if path is None: logger.debug("Could not find the Quanty executable." 'Please set it up using the "Preferences" dialog.') return path
def findBackends(settings: QSettings) -> Munch: tools = Munch(ffmpeg=None, ffprobe=None, mediainfo=None) settings.beginGroup('tools') tools.ffmpeg = settings.value('ffmpeg', None, type=str) tools.ffprobe = settings.value('ffprobe', None, type=str) tools.mediainfo = settings.value('mediainfo', None, type=str) for tool in list(tools.keys()): path = tools[tool] if path is None or not len(path) or not os.path.isfile(path): for exe in VideoService.config.binaries[os.name][tool]: if VideoService.frozen: binpath = VideoService.getAppPath( os.path.join('bin', exe)) else: binpath = QStandardPaths.findExecutable(exe) if not len(binpath): binpath = QStandardPaths.findExecutable( exe, [VideoService.getAppPath('bin')]) if os.path.isfile(binpath) and os.access(binpath, os.X_OK): tools[tool] = binpath if not VideoService.frozen: settings.setValue(tool, binpath) break settings.endGroup() if tools.ffmpeg is None: raise ToolNotFoundException('FFmpeg missing') if tools.ffprobe is None: raise ToolNotFoundException('FFprobe missing') if tools.mediainfo is None: raise ToolNotFoundException('MediaInfo missing') return tools
def findQuanty(): if sys.platform == "win32": executable = "Quanty.exe" else: executable = "Quanty" envPath = QStandardPaths.findExecutable(executable) localPath = resourceAbsolutePath(os.path.join("quanty", "bin")) localPath = QStandardPaths.findExecutable(executable, [localPath]) # Check if Quanty is in the paths defined in the $PATH. if envPath: path = envPath # Check if Quanty is bundled with Crispy. elif localPath: path = localPath else: path = None return path
def quantyFindPath(): if sys.platform in 'win32': executable = 'Quanty.exe' else: executable = 'Quanty' envPath = QStandardPaths.findExecutable(executable) localPath = QStandardPaths.findExecutable( executable, [resourceFileName( 'crispy:' + os.path.join('modules', 'quanty', 'bin'))]) # Check if Quanty is in the paths defined in the $PATH. if envPath: path = os.path.dirname(envPath) # Check if Quanty is bundled with Crispy. elif localPath: path = os.path.dirname(localPath) else: path = None return path, executable
def findExecutable(self): wget = QStandardPaths.findExecutable("wget") if wget != "": print(f"found wget at {wget} *** recording available") self.statusLabel.setText("Aufnahmen möglich") self.showTrayMessage("Hinweis", "wget gefunden\nAufnahmen möglich", self.tIcon) self.recording_enabled = True else: self.showTrayMessage( "Hinweis", "wget icht gefunden\nkeine Aufnahmen möglich", self.tIcon) print("wget icht gefunden\nkeine Aufnahmen möglich") self.recording_enabled = False
def run(self): print("started") cli = [] cmd = "" t = "" self.textWindow.setFocus() self.textWindow.appendPlainText(self.commandfield.toPlainText()) cli = shlex.split(self.commandfield.toPlainText().replace( self.name, '').replace("'", '"'), posix=False) cmd = str(cli[0]) ### is the executable if cmd == "exit": quit() elif cmd == "cd": del cli[0] path = " ".join(cli) os.chdir(os.path.abspath(path)) self.process.setWorkingDirectory(os.getcwd()) print("workingDirectory:", self.process.workingDirectory()) self.cursorEnd() else: self.process.setWorkingDirectory(os.getcwd()) print("workingDirectory", self.process.workingDirectory()) del cli[0] if (QStandardPaths.findExecutable(cmd)): self.commandslist.append( self.commandfield.toPlainText().replace(self.name, "")) print("command", cmd, "found") t = " ".join(cli) if self.process.state() != 2: #self.process.waitForStarted() self.process.waitForReadyRead() self.process.waitForFinished() if "|" in t or ">" in t or "<" in t: print("special characters") self.process.start('sh -c "' + cmd + ' ' + t + '"') print("running", ('sh -c "' + cmd + ' ' + t + '"')) else: self.process.start(cmd + " " + t) print("running", (cmd + " " + t)) else: print("command not found ...") self.textWindow.appendPlainText("command not found ...") self.cursorEnd()
def is_tool(self, name): tool = QStandardPaths.findExecutable(name) if tool != "": return True else: return False
def run(self): self.textWindow.setFocus() self.textWindow.appendPlainText(self.cmdField.toPlainText()) cli = shlex.split(self.cmdField.toPlainText().replace( self.getUsername(), '').replace("'", '"'), posix=False) cmd = str(cli[0]) ### is the executable if cmd == "exit": quit() elif 'cd' in cmd: if len(cli) == 1: command_argument = cmd.split('cd')[1] else: command_argument = cli[1] if cmd == 'cd' or cmd == 'cd.': if len(cli) == 1: pass else: if os.path.isdir(command_argument): # print('{0} is dir'.format(command_argument)) check = True for char in command_argument: if not char == '.': check = False break if not check: pth = os.path.join(self._cwd, command_argument) if os.path.exists(pth): self._cwd = pth else: self.command_not_found(cmd) else: # print('{0} is not dir'.format(command_argument)) pass else: if os.path.exists(command_argument): # print('{0} is path'.format(command_argument)) self._cwd = command_argument else: # print('{0} is path but not exists'.format(command_argument)) pth = os.path.join(self._cwd, command_argument) # print(pth, self._cwd) if os.path.exists(pth): self._cwd = pth else: self.command_not_found(cmd) else: if len(command_argument) <= 1: if command_argument == '/' or command_argument == '\\': self._cwd = os.path.splitdrive(self._cwd)[0] + '/' else: self.command_not_found() elif len(command_argument) >= 2: if command_argument[0:2] == '..': check = True for char in command_argument: if not char == '.': check = False if check: for i in range(len(command_argument) - 1): self._cwd = os.path.dirname(self._cwd) else: self.command_not_found(cmd) else: self.command_not_found(cmd) else: self.command_not_found(cmd) self.updateWorkingDirectory(self._cwd) else: if (QStandardPaths.findExecutable(cmd)): self.commands.append(self.cmdField.toPlainText().replace( self.getUsername(), "")) # print("command", cmd, "found") t = " ".join(cli) if self.process.state() != 2: self.process.waitForStarted() self.process.waitForFinished() if "|" in t or ">" in t or "<" in t: # print("special characters") self.process.start('sh -c "' + cmd + ' ' + t + '"') # print("running", ('sh -c "' + cmd + ' ' + t + '"')) else: self.process.start(cmd + " " + t) # print("running", (cmd + " " + t)) else: self.command_not_found(cmd)