def _find_devenv_path(vs_version): devenv_path = None # First try the registry, because the environment variable is unreliable # (case of Visual Studio installed on a different drive; it still sets # the envvar to point to C:\Program Files even if devenv.com is on D:\) #pylint: disable=import-error from winreg import OpenKey, QueryValue, HKEY_LOCAL_MACHINE key_path = 'SOFTWARE\\Classes\\VisualStudio.accessor.' + vs_version + '.0\\shell\\Open' try: with OpenKey(HKEY_LOCAL_MACHINE, key_path) as key: cmdline = QueryValue(key, 'Command') if cmdline[:1] == '"': cmdline = cmdline.split('"')[1] elif ' ' in cmdline: cmdline = cmdline.split(' ')[0] devenv_path = cmdline.replace('devenv.exe', 'devenv.com') #pylint: disable=broad-except except Exception: pass # If the registry key is unhelpful, try the environment variable if not devenv_path: vstools_path = os.getenv('VS' + vs_version + '0COMNTOOLS') if vstools_path is not None: # Sanitize this because os.path.join sometimes gets confused if vstools_path[-1] in [ '/', '\\' ]: vstools_path = vstools_path[:-1] devenv_path = os.path.join(vstools_path, '../../Common7/IDE/devenv.com') if not devenv_path or not os.path.exists(devenv_path): return None logging.info("Found Visual Studio at %s", devenv_path) return devenv_path
def _find_devenv_path(vs_version): devenv_path = None # Sanitize vs_version if vs_version == '2015': vs_version = '14' if vs_version == '2017': vs_version = '15' if vs_version == '2019': vs_version = '16' # First try the registry, because the environment variable is unreliable # (case of Visual Studio installed on a different drive; it still sets # the envvar to point to C:\Program Files even if devenv.com is on D:\) #pylint: disable=import-error from winreg import OpenKey, QueryValue, HKEY_LOCAL_MACHINE key_path = 'SOFTWARE\\Classes\\VisualStudio.accessor.' + vs_version + '.0\\shell\\Open' try: with OpenKey(HKEY_LOCAL_MACHINE, key_path) as key: cmdline = QueryValue(key, 'Command') if cmdline[:1] == '"': cmdline = cmdline.split('"')[1] elif ' ' in cmdline: cmdline = cmdline.split(' ')[0] devenv_path = cmdline.replace('devenv.exe', 'devenv.com') #pylint: disable=broad-except except Exception: pass # For VS2017 and later, there is vswhere if not devenv_path: vswhere_path = os.path.join(os.environ['ProgramFiles(x86)'], 'Microsoft Visual Studio/Installer/vswhere.exe') result, output, _ = nimp.sys.process.call([vswhere_path], capture_output=True, hide_output=True) if result == 0: for line in output.split('\n'): line = line.strip() if 'installationPath: ' in line: candidate = line.split(' ', 1)[1] elif 'installationVersion: ' + vs_version in line: devenv_path = os.path.join(candidate, 'Common7/IDE/devenv.com') break # If the registry key is unhelpful, try the environment variable if not devenv_path: vstools_path = os.getenv('VS' + vs_version + '0COMNTOOLS') if vstools_path is not None: # Sanitize this because os.path.join sometimes gets confused if vstools_path[-1] in [ '/', '\\' ]: vstools_path = vstools_path[:-1] devenv_path = os.path.join(vstools_path, '../../Common7/IDE/devenv.com') if not devenv_path or not os.path.exists(devenv_path): return None devenv_path = os.path.normpath(devenv_path) logging.info("Found Visual Studio at %s", devenv_path) return devenv_path
def qadShowPluginHelp(section="", filename="index", packageName=None): """ show a help in the user's html browser. per conoscere la sezione/pagina del file html usare internet explorer, selezionare nella finestra di destra la voce di interesse e leggerne l'indirizzo dalla casella in alto. Questo perché internet explorer inserisce tutti i caratteri di spaziatura e tab che gli altri browser non fanno. """ try: basepath = "" if packageName is None: basepath = os.path.dirname(os.path.realpath(__file__)) else: basepath = os.path.dirname( os.path.realpath(sys.modules[packageName].__file__)) except: return # initialize locale userLocaleList = QSettings().value("locale/userLocale").split("_") language = userLocaleList[0] region = userLocaleList[1] if len(userLocaleList) > 1 else "" path = QDir.cleanPath(basepath + "/help/help") helpPath = path + "_" + language + "_" + region # provo a caricare la lingua e la regione selezionate if not os.path.exists(helpPath): helpPath = path + "_" + language # provo a caricare la lingua if not os.path.exists(helpPath): helpPath = path + "_en" # provo a caricare la lingua inglese if not os.path.exists(helpPath): return helpfile = os.path.join(helpPath, filename + ".html") if os.path.exists(helpfile): url = "file:///" + helpfile if section != "": url = url + "#" + urllib.parse.quote(section.encode('utf-8')) # la funzione QDesktopServices.openUrl in windows non apre la sezione if platform.system() == "Windows": import subprocess from winreg import HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, OpenKey, QueryValue try: # provo a livello di utente with OpenKey( HKEY_CURRENT_USER, r"Software\Classes\http\shell\open\command") as key: cmd = QueryValue(key, None) except: # se non c'era a livello di utente provo a livello di macchina with OpenKey( HKEY_LOCAL_MACHINE, r"Software\Classes\http\shell\open\command") as key: cmd = QueryValue(key, None) if cmd.find("\"%1\"") >= 0: subprocess.Popen(cmd.replace("%1", url)) else: if cmd.find("%1") >= 0: subprocess.Popen(cmd.replace("%1", "\"" + url + "\"")) else: subprocess.Popen(cmd + " \"" + url + "\"") else: QDesktopServices.openUrl(QUrl(url))