def register_X_controllers(): if _iscommand('kfmclient'): _controllers['kde-open'] = KfmClient() for command in ('gnome-open', 'exo-open', 'xdg-open'): if _iscommand(command): _controllers[command] = Controller(command)
def getBrowserList(): browsers = [] default = getDefaultBrowser() if default: browsers = [ default, ] for name in browserNames: if name == default: continue try: wb.get(name) browsers.append(name) except: try: if wb._iscommand(name): wb.register(name, None, wb.Netscape(name)) wb.get(name) browsers.append(name) except: continue return browsers
def _register_gvfs_open(): ''' GVFS is the virtual file system for the GNOME desktop gvfs-open opens a file in the using the appropriate applicatioin when the user is using the GNOME desktop ''' if 'GNOME_DESKTOP_SESSION_ID' in os.environ and _iscommand('gvfs-open'): register('gvfs-open', None, BackgroundBrowser('gvfs-open'))
def browser_open(url): if sys.platform == 'darwin': os.system('open %s &' % url) else: import webbrowser if webbrowser._iscommand('firefox'): # Firefox is installed, let's use it, we know how to make it chromeless. firefox = webbrowser.get('firefox') firefox._invoke(['-chrome', url], remote=False, autoraise=True) else: webbrowser.open(url)
def browser_open(url): if sys.platform == 'darwin': os.system('open %s &' % url) else: import webbrowser if webbrowser._iscommand('firefox') and \ preference_manager.root.open_help_in_light_browser: # Firefox is installed, let's use it, we know how to make it # chromeless. firefox = webbrowser.get('firefox') firefox._invoke(['-chrome', url], remote=False, autoraise=True) else: webbrowser.open(url, autoraise=1)
def startfile(filepath): if sys.platform[:3] == 'win': os.startfile(filepath) return True elif sys.platform == 'darwin': subprocess.call('open', filepath) return True elif sys.platform.startswith('linux'): for command in ('gnome-open', 'kde-open', 'exo-open', 'xdg-open'): if webbrowser._iscommand(command): subprocess.call(command, filepath) return True return False
def new_webbrowser_profile(): if webbrowser._iscommand('google-chrome'): new_chrome = webbrowser.Chrome() new_chrome.name = 'google-chrome' profile_directory = tempfile.mkdtemp() new_chrome.remote_args = webbrowser.Chrome.remote_args + [ '--user-data-dir="{}"'.format(profile_directory) ] return new_chrome elif webbrowser._iscommand('firefox'): new_firefox = webbrowser.Mozilla() new_firefox.name = 'firefox' profile_directory = tempfile.mkdtemp() new_firefox.remote_args = [ '-profile', profile_directory, '-new-instance', '-no-remote', '-url', '%s', ] return new_firefox else: return webbrowser
def __init__(self): self.clipboard = anyos.Clipboard() self.hotkey = anyos.Hotkey() louie.connect(self.on_hotkey, self.hotkey.event) self.network = Network('192.168.0.255', 45644) louie.connect(self.on_command, self.network.command) self.hotkey.add_bind('CLIPBOARD', '<control><alt>C') self.hotkey.add_bind('URL', '<control><alt>B') chrome = os.path.join(os.environ.get('LOCALAPPDATA') or '', 'Google\\Chrome\\Application\\chrome.exe') extra_browsers = [chrome, 'chrome.exe'] for browser in extra_browsers: if webbrowser._iscommand(browser): webbrowser.register(browser, None, webbrowser.BackgroundBrowser(browser), -1)
def browser_open(url, decorated = False): import os import sys if sys.platform == 'darwin': os.system('open %s &' % url) else: import webbrowser if webbrowser._iscommand('firefox') and \ preference_manager.root.open_help_in_light_browser: # Firefox is installed, let's use it, we know how to make it # chromeless. if decorated: webbrowser.open(url, autoraise=1) else: firefox = webbrowser.get('firefox') firefox._invoke(['-chrome', url], remote=False, autoraise=True) else: webbrowser.open(url, autoraise=1)
import os import sys import webbrowser from PyQt4 import QtGui """ A webbrowser extension that respects user's preferred browser on each platform. Python 2.5 already has *some* support for this, but it's not enough, in my opinion. See also: http://sourceforge.net/tracker/index.php?func=detail&aid=1681228&group_id=5470&atid=105470 """ if sys.version_info >= (2, 5): # Cross-platform default tool if webbrowser._iscommand('xdg-open'): webbrowser.register('xdg-open', None, webbrowser.BackgroundBrowser(["xdg-open", "%s"]), update_tryorder=-1) else: # KDE default browser if 'KDE_FULL_SESSION' in os.environ and os.environ['KDE_FULL_SESSION'] == 'true' and webbrowser._iscommand('kfmclient'): webbrowser.register('kfmclient', None, webbrowser.BackgroundBrowser(["kfmclient", "exec", "%s"]), update_tryorder=-1) # GNOME default browser if 'GNOME_DESKTOP_SESSION_ID' in os.environ and webbrowser._iscommand('gnome-open'): webbrowser.register('gnome-open', None, webbrowser.BackgroundBrowser(["gnome-open", "%s"]), update_tryorder=-1) else: # KDE default browser if 'KDE_FULL_SESSION' in os.environ and os.environ['KDE_FULL_SESSION'] == 'true' and webbrowser._iscommand('kfmclient'): webbrowser.register('kfmclient', None, webbrowser.GenericBrowser("kfmclient exec '%s' &")) if 'BROWSER' in os.environ:
def _open_link(widget, uri): for cmd in ["sensible-browser", "xdg-open"]: if webbrowser._iscommand(cmd): webbrowser._tryorder.insert(0, '%s "%%s"' % cmd) webbrowser.open(uri)
def wireshark(filepath): if webbrowser._iscommand('wireshark'): subprocess.call('wireshark', filepath) return True return False
def open(url, desktop=None, wait=0): """ Open the 'url' in the current desktop's preferred file browser. If the optional 'desktop' parameter is specified then attempt to use that particular desktop environment's mechanisms to open the 'url' instead of guessing or detecting which environment is being used. Suggested values for 'desktop' are "standard", "KDE", "GNOME", "XFCE", "Mac OS X", "Windows" where "standard" employs a DESKTOP_LAUNCH environment variable to open the specified 'url'. DESKTOP_LAUNCH should be a command, possibly followed by arguments, and must have any special characters shell-escaped. The process identifier of the "opener" (ie. viewer, editor, browser or program) associated with the 'url' is returned by this function. If the process identifier cannot be determined, None is returned. An optional 'wait' parameter is also available for advanced usage and, if 'wait' is set to a true value, this function will wait for the launching mechanism to complete before returning (as opposed to immediately returning as is the default behaviour). """ # Decide on the desktop environment in use. desktop_in_use = use_desktop(desktop) if desktop_in_use == "standard": arg = "".join([os.environ["DESKTOP_LAUNCH"], subprocess.mkarg(url)]) return _run(arg, 1, wait) elif desktop_in_use == "Windows": # NOTE: This returns None in current implementations. return os.startfile(url) elif desktop_in_use == "Mac OS X": cmd = ["open", url] elif _iscommand("xdg-open"): cmd = ["xdg-open", url] elif desktop_in_use == "KDE4": cmd = ["kioclient", "exec", url] elif desktop_in_use == "KDE": cmd = ["kfmclient", "exec", url] elif desktop_in_use == "GNOME": if _iscommand("gvfs-open"): cmd = ["gvfs-open"] else: cmd = ["gnome-open"] cmd.append(url) elif desktop_in_use == "XFCE": cmd = ["exo-open", url] elif desktop_in_use == "X11" and "BROWSER" in os.environ: cmd = [os.environ["BROWSER"], url] # Finish with an error where no suitable desktop was identified. else: raise OSError( "Desktop '%s' not supported (neither DESKTOP_LAUNCH nor os.startfile could be used)" % desktop_in_use ) return _run(cmd, 0, wait)
def _register_gvfs_open(): ''' ''' if 'GNOME_DESKTOP_SESSION_ID' in os.environ and _iscommand('gvfs-open'): register('gvfs-open', None, BackgroundBrowser('gvfs-open'))
import os import sys import webbrowser from PyQt4 import QtGui from picard.const import PICARD_URLS """ A webbrowser extension that respects user's preferred browser on each platform. Python 2.5 already has *some* support for this, but it's not enough, in my opinion. See also: http://sourceforge.net/tracker/index.php?func=detail&aid=1681228&group_id=5470&atid=105470 """ if sys.version_info >= (2, 5): # Cross-platform default tool if webbrowser._iscommand('xdg-open'): webbrowser.register('xdg-open', None, webbrowser.BackgroundBrowser(["xdg-open", "%s"]), update_tryorder=-1) else: # KDE default browser if 'KDE_FULL_SESSION' in os.environ and os.environ['KDE_FULL_SESSION'] == 'true' and webbrowser._iscommand('kfmclient'): webbrowser.register('kfmclient', None, webbrowser.BackgroundBrowser(["kfmclient", "exec", "%s"]), update_tryorder=-1) # GNOME default browser if 'XDG_CURRENT_DESKTOP' in os.environ and os.environ['XDG_CURRENT_DESKTOP'].lower() == 'gnome' and webbrowser._iscommand('gnome-open'): webbrowser.register('gnome-open', None, webbrowser.BackgroundBrowser(["gnome-open", "%s"]), update_tryorder=-1) else: # KDE default browser if 'KDE_FULL_SESSION' in os.environ and os.environ['KDE_FULL_SESSION'] == 'true' and webbrowser._iscommand('kfmclient'): webbrowser.register('kfmclient', None, webbrowser.GenericBrowser("kfmclient exec '%s' &")) if 'BROWSER' in os.environ:
def _register_google_chrome(): ''' ''' for browser in ('google-chrome', 'chrome', 'chromium', 'chromium-browser'): if _iscommand(browser): register(browser, None, Chrome(browser))
def _register_xdg_open(): ''' Opens a URL or file in the user's preferred browser or application ''' if _iscommand('xdg-open'): register('xdg-open', None, BackgroundBrowser('xdg-open'))
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import os import sys import webbrowser from PyQt4 import QtGui """ A webbrowser extension that respects user's preferred browser on each platform. Python 2.5 already has *some* support for this, but it's not enough, in my opinion. See also: http://sourceforge.net/tracker/index.php?func=detail&aid=1681228&group_id=5470&atid=105470 """ if sys.version_info >= (2, 5): # Cross-platform default tool if webbrowser._iscommand('xdg-open'): webbrowser.register('xdg-open', None, webbrowser.BackgroundBrowser(["xdg-open", "%s"]), update_tryorder=-1) else: # KDE default browser if 'KDE_FULL_SESSION' in os.environ and os.environ[ 'KDE_FULL_SESSION'] == 'true' and webbrowser._iscommand( 'kfmclient'): webbrowser.register('kfmclient', None, webbrowser.BackgroundBrowser( ["kfmclient", "exec", "%s"]), update_tryorder=-1) # GNOME default browser
import os import sys import webbrowser from PyQt5 import QtWidgets from picard.const import PICARD_URLS """ A webbrowser extension that respects user's preferred browser on each platform. Python 2.5 already has *some* support for this, but it's not enough, in my opinion. See also: http://sourceforge.net/tracker/index.php?func=detail&aid=1681228&group_id=5470&atid=105470 """ if sys.version_info >= (2, 5): # Cross-platform default tool if webbrowser._iscommand('xdg-open'): webbrowser.register('xdg-open', None, webbrowser.BackgroundBrowser(["xdg-open", "%s"]), update_tryorder=-1) else: # KDE default browser if 'KDE_FULL_SESSION' in os.environ and os.environ[ 'KDE_FULL_SESSION'] == 'true' and webbrowser._iscommand( 'kfmclient'): webbrowser.register('kfmclient', None, webbrowser.BackgroundBrowser( ["kfmclient", "exec", "%s"]), update_tryorder=-1) # GNOME default browser
def open(url, desktop=None, wait=0): """ Open the 'url' in the current desktop's preferred file browser. If the optional 'desktop' parameter is specified then attempt to use that particular desktop environment's mechanisms to open the 'url' instead of guessing or detecting which environment is being used. Suggested values for 'desktop' are "standard", "KDE", "GNOME", "XFCE", "Mac OS X", "Windows" where "standard" employs a DESKTOP_LAUNCH environment variable to open the specified 'url'. DESKTOP_LAUNCH should be a command, possibly followed by arguments, and must have any special characters shell-escaped. The process identifier of the "opener" (ie. viewer, editor, browser or program) associated with the 'url' is returned by this function. If the process identifier cannot be determined, None is returned. An optional 'wait' parameter is also available for advanced usage and, if 'wait' is set to a true value, this function will wait for the launching mechanism to complete before returning (as opposed to immediately returning as is the default behaviour). """ # Decide on the desktop environment in use. desktop_in_use = use_desktop(desktop) if desktop_in_use == "standard": arg = "".join([os.environ["DESKTOP_LAUNCH"], subprocess.mkarg(url)]) return _run(arg, 1, wait) elif desktop_in_use == "Windows": # NOTE: This returns None in current implementations. return os.startfile(url) elif desktop_in_use == "Mac OS X": cmd = ["open", url] elif _iscommand("xdg-open"): cmd = ["xdg-open", url] elif desktop_in_use == "KDE4": cmd = ["kioclient", "exec", url] elif desktop_in_use == "KDE": cmd = ["kfmclient", "exec", url] elif desktop_in_use == "GNOME": if _iscommand("gvfs-open"): cmd = ["gvfs-open"] else: cmd = ["gnome-open"] cmd.append(url) elif desktop_in_use == "XFCE": cmd = ["exo-open", url] elif desktop_in_use == "X11" and "BROWSER" in os.environ: cmd = [os.environ["BROWSER"], url] # Finish with an error where no suitable desktop was identified. else: raise OSError( "Desktop '%s' not supported (neither DESKTOP_LAUNCH nor os.startfile could be used)" % desktop_in_use) return _run(cmd, 0, wait)
#Embedded file name: dropbox/url_info.py from __future__ import absolute_import import webbrowser import urllib import multiprocessing import os from Crypto.Random import random from webbrowser import _iscommand, register, BackgroundBrowser from dropbox.debugging import easy_repr from dropbox.i18n import get_requested_code from dropbox.language_data import SYSTEM_LANG_CODE from dropbox.monotonic_time import get_monotonic_time from dropbox.platform import platform from dropbox.trace import unhandled_exc_handler, TRACE from build_number import BUILD_KEY, USABILITY if _iscommand('x-www-browser'): register('x-www-browser', None, BackgroundBrowser('x-www-browser')) browser_launcher = webbrowser if platform == 'win': from pynt.dlls.shlwapi import shlwapi from pynt.constants import S_FALSE from ctypes import create_unicode_buffer, byref from ctypes.wintypes import LPCWSTR, DWORD import subprocess32 as subprocess def open_url(full_url): outsize = DWORD(0) assname = 'http' try: shlwapi.AssocQueryStringW(0, 1, LPCWSTR(assname), None, None, byref(outsize)) except WindowsError as e:
def fix_webbrowser(): 'enable chromium browser support' for browser in ("xdg-open", "chromium-browser", "chrome", "chromium","chrome-browser"): if webbrowser._iscommand(browser): webbrowser.register(browser, None, webbrowser.BackgroundBrowser(browser))
def _register_xdg_open(): ''' ''' if _iscommand('xdg-open'): register('xdg-open', None, BackgroundBrowser('xdg-open'))