def execOpenOnDesktop(cls, file_): """ generated source for method execOpenOnDesktop """ pattern = re.compile("[^a-zA-Z0-9_().-~]") matcher = pattern.matcher(file_.__name__) fileName = matcher.replaceAll("_") newFile = os.path.join(file_.getParent(), fileName) if not file_.__name__ == fileName: os.rename(file_, newFile) file_ = newFile f = os.path.abspath(file_) #r = Runtime.getRuntime() p = None if OS.isLinux(): try: p = os.system("xdg-open \"%s\"" %f) except (Exception) as e: sys.stdout.write(e) # String subCmd = (exec) ? "exec" : "openURL"; elif OS.isMac(): try: p = os.system("open \"%s\"" %f) except (Exception) as e: sys.stdout.write(e) elif OS.isWindows(): if OS.isWindows9X(): try: p = os.system("command.com /C start %s" %f) except (Exception) as e: sys.stdout.write(e) # "command.com /C \"start " + f + "\"" else: p = subprocess.Popen(["cmd.exe", "/C", "start", f], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) p.wait() res = p.stdout.readlines() if p.returncode: for errLine in res: if errLine.startswith("\\\\"): UNCError = True else: sys.stdout.write(" >%s" %errLine) return None else: return file_