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_
def getWorkingDirectory(cls, appName): """ generated source for method getWorkingDirectory """ s = os.path.sep userHome = System.getProperty("user.home", ".") dir_ = File() if OS.isLinux(): dir_ = File(userHome, s + appName) elif OS.isSolaris(): dir_ = File(userHome + s + appName) elif OS.isWindows(): if applicationData != None: dir_ = File(applicationData + s + appName) else: dir_ = File(userHome + s + appName) elif OS.isMac(): dir_ = File(userHome, "Library" + s + "Application Support" + s + appName) else: dir_ = File(".") if not dir.exists() and not dir.mkdirs(): dir_ = File(System.getProperty("java.io.tmpdir")) dir_ = File(dir.getAbsoluteFile() + ("" if dir.getAbsolutePath().endsWith(s) else s) + appName) if not dir.exists(): dir.mkdirs() return dir.getAbsolutePath()