def open_chrome():
    urL = 'https://www.google.com'
    chrome_path = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
    webbrowser.register('chrome', None,
                        webbrowser.BackgroundBrowser(chrome_path))
    webbrowser.get('chrome').open_new_tab(urL)
    return
Example #2
0
 def __init__(self, browser, session):
     self.jd = JSONDecoder()
     self.browser = browser
     self.windows = {}
     webbrowser.register(self.browser, None,
                         webbrowser.Chrome(self.browser))
     self.tabs = self._set_session(session)
Example #3
0
def chrome():
    speak("¿Que quieres buscar?")
    chromepath = ("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe")
    search = takeCommand().lower()
    wb.register("chrome", None,wb.BackgroundBrowser(chromepath))
    b = wb.get("chrome")
    b.open_new_tab(search)
def main():
    try:
        buildServer = run_local_build_server()
        while not is_build_server_running():
            print "[build server] BOOTING"
        print "[build server] ONLINE"

        appInventor = start_appinventor()
        while not is_app_inventor_running():
            print "[app inventor] BOOTING"
        print "[app inventor] ONLINE"

        print "[app inventor] OPENING"
        try:
            browser = webbrowser.get("chrome")
        except webbrowser.Error:
            try:
                webbrowser.register("firefox", None, webbrowser.GenericBrowser(os.environ["ProgramFiles"] + r"\Mozilla Firefox\firefox.exe"), 1)
                browser = webbrowser.get("firefox")
            except webbrowser.Error:
                browser = webbrowser.get()
        browser.open("http://localhost:8888/_ah/login?continue=http://localhost:8888/")
    except Exception as e:
        print type(e)
        print e
    finally:
        taskkill(buildServer.pid)
        taskkill(appInventor.pid)
Example #5
0
def setbrowser(browser=None):
    """ Registers the given browser and saves it as the module default.
        This is used to control which browser is used to display the plot.
        The argument should be a value that can be passed to webbrowser.get()
        to obtain a browser.  If no argument is given, the default is reset
        to the system default.

        webbrowser provides some predefined browser names, including:
        'firefox'
        'opera'

        If the browser string contains '%s', it is interpreted as a literal
        browser command line.  The URL will be substituted for '%s' in the command.
        For example:
        'google-chrome %s'
        'cmd "start iexplore.exe %s"'

        See the webbrowser documentation for more detailed information.

        Note: Safari does not reliably work with the webbrowser module,
        so we recommend using a different browser.
    """
    global _browser
    if browser is None:
        _browser = None  # Use system default
    else:
        webbrowser.register(browser, None, webbrowser.get(browser))
        _browser = browser
Example #6
0
def set_config():
    """Set optional API keys, browser, and bookmarks in CONFIG."""
    for key, val in iteritems(read_config()):
        CONFIG[key] = val

    if 'browser' in CONFIG and CONFIG['browser'] != 'Automatically detected':
        try:
            CONFIG['browser_obj'] = webbrowser.get(CONFIG['browser'])
            return
        except webbrowser.Error as err:
            sys.stderr.write('{} at {}\n'.format(str(err), CONFIG['browser']))
            CONFIG['browser_obj'] = None
            pass
        except IndexError:
            CONFIG['browser_obj'] = None
            pass

    # If no valid browser found then use webbrowser to automatically detect one
    try:
        supported_platforms = {'win32': 'windows-default', 'cygwin': 'cygstart', 'darwin': 'macosx'}
        if sys.platform not in supported_platforms:
            browser_name = 'Automatically detected'
            browser_obj = webbrowser.get()
        else:
            browser_name = supported_platforms[sys.platform]
            if browser_name == 'cygstart':
                # Cygwin requires us to register browser type (or export BROWSER='cygstart')
                webbrowser.register(browser_name, None, webbrowser.GenericBrowser(browser_name))
            browser_obj = webbrowser.get(browser_name)

        CONFIG['browser'] = browser_name
        CONFIG['browser_obj'] = browser_obj
    except webbrowser.Error:
        pass
Example #7
0
def patch_webbrowser():
    """
    Patch webbrowser on macOS to support setting BROWSER=firefox,
    BROWSER=chrome, etc..

    https://bugs.python.org/issue31348
    """

    # Add support for browsers that aren't defined in the python standard library
    webbrowser.register('surf', None, webbrowser.BackgroundBrowser('surf'))
    webbrowser.register('vimb', None, webbrowser.BackgroundBrowser('vimb'))

    # Fix the opera browser, see https://github.com/michael-lazar/rtv/issues/476.
    # By default, opera will open a new tab in the current window, which is
    # what we want to do anyway.
    webbrowser.register('opera', None, webbrowser.BackgroundBrowser('opera'))

    if sys.platform != 'darwin' or 'BROWSER' not in os.environ:
        return

    # This is a copy of what's at the end of webbrowser.py, except that
    # it adds MacOSXOSAScript entries instead of GenericBrowser entries.
    _userchoices = os.environ["BROWSER"].split(os.pathsep)
    for cmdline in reversed(_userchoices):
        if cmdline in ('safari', 'firefox', 'chrome', 'default'):
            browser = webbrowser.MacOSXOSAScript(cmdline)
            try:
                webbrowser.register(cmdline, None, browser, update_tryorder=-1)
            except TypeError:
                # 3.7 nightly build changed the method signature
                # pylint: disable=unexpected-keyword-arg
                webbrowser.register(cmdline, None, browser, preferred=True)
def connFun(dname,IPs):
    # packets = sniff(store=1,prn=handlePacket,filter="host 61.135.169.125",count=5)
    # packets = sniff(prn=lambda x: x.summary(), lfilter=lambda x: TLS in x)

    # 调用浏览器访问
    chromepath = r'C:\Users\ipc\AppData\Local\Google\Chrome\Application\chrome.exe'
    web.register('chrome', None, web.BackgroundBrowser(chromepath))
    web.get('chrome').open(dname, new=1, autoraise=True)

    # sr1(IP(dst=dname)/TCP()/"GET / HTTP/1.1\r\nHost: 192.168.1.104\r\n\r\nHEAD = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0'}\r\n\r\n")

    packets = sniff(prn=handlePacket, lfilter= lambda x: TLS in x and (x.haslayer('IP')) and (x['IP'].src in IPs or x['IP'].dst in IPs), timeout = 10)

    # 关闭浏览器
    os.system('taskkill /F /IM chrome.exe')
    # buildConn(dname)

    if packets:
        print(packets)
    else:
        print("nonononono packets")
        web.get('chrome').open(dname, new=1, autoraise=True)
        packets = sniff(prn=handlePacket, lfilter=lambda x: x.haslayer('IP') and (x['IP'].src in IPs or x['IP'].dst in IPs), timeout=10)
        os.system('taskkill /F /IM chrome.exe')
        if packets:
            print(packets)
        else:
            print('还是没有')

    filepath = "C:\\Users\\ipc\\Desktop\\TLS_Project\\datapackets\\" + dname.replace(".", "_") + ".pcap"
    if not os.path.exists(filepath):
        f = open(filepath, 'w')
        f.close()
    wrpcap(filepath, packets)
Example #9
0
def setbrowser(browser=None):
    """ Registers the given browser and saves it as the module default.
        This is used to control which browser is used to display the plot.
        The argument should be a value that can be passed to webbrowser.get()
        to obtain a browser.  If no argument is given, the default is reset
        to the system default.

        webbrowser provides some predefined browser names, including:
        'firefox'
        'opera'

        If the browser string contains '%s', it is interpreted as a literal
        browser command line.  The URL will be substituted for '%s' in the command.
        For example:
        'google-chrome %s'
        'cmd "start iexplore.exe %s"'

        See the webbrowser documentation for more detailed information.

        Note: Safari does not reliably work with the webbrowser module,
        so we recommend using a different browser.
    """
    global _browser
    if browser is None:
        _browser = None  # Use system default
    else:
        webbrowser.register(browser, None, webbrowser.get(browser))
        _browser = browser
def progress():
    # 填充进度条
    fill_line = canvas.create_rectangle(1.5, 1.5, 0, 23, width=0, fill="green")
    x = 500  # 未知变量,可更改
    n = 465 / x  # 465是矩形填充满的次数
    for i in range(x):
        n = n + 465 / x
        canvas.coords(fill_line, (0, 0, n, 60))
        window.update()
        time.sleep(0.02)  # 控制进度条流动的速度
    IEPath = "/usr/bin/firefox"
    webbrowser.register('IE', None, webbrowser.BackgroundBrowser(IEPath))
    webbrowser.get('IE').open(
        'http://192.168.1.126:8080/index.html#/dashboard?job_id=201908250954493676949&role=guest&party_id=10000',
        new=1,
        autoraise=True)
    # 或者
    webbrowser.open_new_tab(
        'http://192.168.1.126:8080/index.html#/dashboard?job_id=201908250954493676949&role=guest&party_id=10000'
    )

    # 清空进度条
    fill_line = canvas.create_rectangle(1.5, 1.5, 0, 23, width=0, fill="white")
    x = 500  # 未知变量,可更改
    n = 465 / x  # 465是矩形填充满的次数

    for t in range(x):
        n = n + 465 / x
        # 以矩形的长度作为变量值更新
        canvas.coords(fill_line, (0, 0, n, 60))
        window.update()
        time.sleep(0)  # 时间为0,即飞速清空进度条
Example #11
0
def respond(voice_data):
    if 'what is your name' in voice_data:
        alexis_speak('my name is Fiona')
    if 'what time is it' in voice_data:
        alexis_speak(ctime())
    if 'who is the richest person' in voice_data:
        alexis_speak('Its sachin ')
    if 'find something' in voice_data:
        search = record_audio('what do you want to search for')
        url = 'https://google.com/search?q=' + search
        webbrowser.register(
            'chrome', None,
            webbrowser.BackgroundBrowser(
                "C://Program Files (x86)//Google//Chrome//Application//chrome.exe"
            ))
        webbrowser.get('chrome').open_new(url)
        alexis_speak('here is what if found for ' + search)
    if 'open email' in voice_data:
        alexis_speak('opening your email')
        subprocess.call(
            ["C:/Program Files (x86)/Mozilla Thunderbird/thunderbird.exe"])
    if 'open my email' in voice_data:
        alexis_speak('opening gmail')
        driver = webdriver.Chrome("chromedriver.exe")
        driver.get("https://gmail.com")
        driver.find_element_by_name("identifier").send_keys("*****@*****.**")
        driver.find_element_by_xpath(
            "//*[@id='identifierNext']/div/button/div[2]").click()
        driver.implicitely_wait(5)
        # above test is failing on next as chrome detects it as not secure

    if 'exit' in voice_data:
        exit()
    return respond
Example #12
0
    def Open(self, argumento, lista, localhost=False):
        path_chrome = sys.argv[0].split("sexta-feira.py")[0]
        webbrowser.register(
            "chrome", None,
            webbrowser.BackgroundBrowser(self.caminho_chrome()))
        try:
            if len(lista) > 0:
                print(self.listar(lista))
                opcao = int(input("\nNúmero do projeto: "))
                site = lista[opcao - 1]
                if opcao in range(0, len(lista) + 1):
                    if localhost:
                        URL = (
                            self.ler_json(False, "./Config")["url"] + "/" if
                            self.ler_json(False, "./Config")["url"][-1] != "/"
                            else self.ler_json(False, "./Config")["url"])
                        destino = URL + site.split(".txt")[0]
                        webbrowser.get("chrome").open(f"{destino}")
                    return (webbrowser.get("chrome").open(
                        f"{path_chrome}/Projetos/Validação/{site}")
                            if " chrome" in argumento else
                            os.system(f"notepad Projetos/Validação/{site}"))
                else:
                    print("Aviso: Projeto não encontrado.")
            else:
                print("Erro: Você não possui projetos validados.")

        except Exception as erro:
            print(f"\n -> { Fore.RED }{erro}{ Fore.WHITE } <-")
            print("\nAviso: Não foi possível selecionar o projeto.")

        return False
Example #13
0
def run_scan():

    IePath = r"C:\Program Files\Google\Chrome\Application\chrome.exe"
    if not os.path.exists(IePath):
        IePath = r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"

    webbrowser.register('Chrome', None, webbrowser.BackgroundBrowser(IePath))

    with open("target.txt", "r") as file_IP:
        ip_content = file_IP.readlines()

    ipCount = len(ip_content)
    if (ipCount % 10 == 0):
        ipLoop_count = int(ipCount // 10)
    else:
        ipLoop_count = int(ipCount // 10) + 1

    IpList = [x.strip() for x in ip_content]

    for round in range(0, ipLoop_count):
        for line0 in IpList[(round * 10):((round + 1) * 10)]:
            if line0.strip().endswith('443'):
                urlIP = "https://" + line0.strip()
            else:
                urlIP = "http://" + line0.strip()

            webbrowser.get("Chrome").open_new_tab(urlIP)

            time.sleep(1)

        print("Press Enter-key to contuine...")
        input()

    print("Press Enter-key to EndApp ^_^")
    input()
Example #14
0
def start_browser(entry):
    if browser and \
       browser not in ('xdg-open', 'start') and \
       not grass.find_program(browser):
        grass.fatal(_("Browser '%s' not found") % browser)

    if flags['o']:
        major,minor,patch = grass.version()['version'].split('.')
        url_path = 'http://grass.osgeo.org/grass%s%s/manuals/%s.html' % (major,minor,entry)
        if urllib.urlopen(url_path).getcode() != 200:
            url_path = 'http://grass.osgeo.org/grass%s%s/manuals/addons/%s.html' % (major,minor,entry)
    else:
        path = os.path.join(gisbase, 'docs', 'html', entry + '.html')
        if not os.path.exists(path) and os.getenv('GRASS_ADDON_BASE'):
            path = os.path.join(os.getenv('GRASS_ADDON_BASE'), 'docs', 'html', entry + '.html')
    
        if not os.path.exists(path):
            grass.fatal(_("No HTML manual page entry for '%s'") % entry)
    
        url_path = 'file://' + path
    
    if browser and browser not in ('xdg-open', 'start'):
        webbrowser.register(browser_name, None)
    
    grass.verbose(_("Starting browser '%(browser)s' for manual"
                    " entry '%(entry)s'...") % \
                  dict(browser=browser_name, entry=entry))
    
    try:
        webbrowser.open(url_path)
    except:
        grass.fatal(_("Error starting browser '%(browser)s' for HTML file"
                      " '%(path)s'") % dict(browser=browser, path=path))
Example #15
0
    def run(self, startURL=""):
        # Get toolingapi settings
        settings = context.get_toolingapi_settings()

        # Combine Login URL
        show_params = {
            "un": settings["username"],
            "pw": settings["password"],
            "startURL": startURL
        }

        if util.is_python3x():
            show_params = urllib.parse.urlencode(show_params)
        else:
            show_params = urllib.urlencode(show_params)

        show_url = settings["login_url"] + '?%s' % show_params

        browser_path = settings["default_browser_path"]
        if os.path.exists(browser_path):
            webbrowser.register('chrome', None,
                                webbrowser.BackgroundBrowser(browser_path))
            webbrowser.get('chrome').open_new_tab(show_url)
        else:
            webbrowser.open_new_tab(show_url)
Example #16
0
def browser_open_url(browser, browser_path, url):
    try:
        webbrowser.register(browser, None,
                            webbrowser.BackgroundBrowser(browser_path))
        webbrowser.get(browser).open(url)
    except Exception as exc:
        pass
Example #17
0
def check_price():
    while True:
        try:
            page = requests.get(URL, headers=headers)
            soup = BeautifulSoup(page.content, 'html.parser')
            price = soup.findAll(
                "strong",
                {"class": "pricelabel__value not-arranged"})[0].string
            converted_price = int(price[:-2].strip())

            print(soup.title.string)
            print("Aktualna Cena Wynosi: " + str(converted_price) + " ZŁ")
            print('Checking...')

            if converted_price <= CENA_KTOREJ_OCZEKUJECIE:
                print("CENA ZOSTAŁA OBNIŻONA!")
                webbrowser.register(
                    'chrome', None,
                    webbrowser.BackgroundBrowser(
                        "C://Program Files (x86)//Google//Chrome//Application//chrome.exe"
                    ))
                webbrowser.get('chrome').open_new(URL)

            time.sleep(2)
        except (ValueError):
            pass
        except (IndexError):
            pass
Example #18
0
def launch_webbrowser(url):
    import webbrowser
    if platform == 'android':
        from jnius import autoclass, cast

        def open_url(url):
            PythonActivity = autoclass('org.kivy.android.PythonActivity')
            activity = PythonActivity.mActivity
            Intent = autoclass('android.content.Intent')
            Uri = autoclass('android.net.Uri')
            browserIntent = Intent()
            browserIntent.setAction(Intent.ACTION_VIEW)
            browserIntent.setData(Uri.parse(url))
            currentActivity = cast('android.app.Activity', activity)
            currentActivity.startActivity(browserIntent)

        # Web browser support.
        class AndroidBrowser(object):
            def open(self, url, new=0, autoraise=True):
                open_url(url)

            def open_new(self, url):
                open_url(url)

            def open_new_tab(self, url):
                open_url(url)

        webbrowser.register('android', AndroidBrowser, None, -1)

    webbrowser.open(url)
Example #19
0
def quest_parser(line, command):
    quest = ["who", "what", "where", "when", "why", "how"]
    url = "https://www.google.com/search?q=" + line
    webbrowser.register('chrome',
	None,
	webbrowser.BackgroundBrowser("C://Program Files (x86)//Google//Chrome//Application//chrome.exe"))
    webbrowser.get('chrome').open_new(url)
Example #20
0
def start_browser(entry):
    if browser and \
       browser not in ('xdg-open', 'start') and \
       not grass.find_program(browser):
        grass.fatal(_("Browser '%s' not found") % browser)

    if flags['o']:
        major, minor, patch = grass.version()['version'].split('.')
        url_path = 'https://grass.osgeo.org/grass%s%s/manuals/%s.html' % (major, minor, entry)
        if urlopen(url_path).getcode() != 200:
            url_path = 'https://grass.osgeo.org/grass%s%s/manuals/addons/%s.html' % (
                major, minor, entry)
    else:
        path = os.path.join(gisbase, 'docs', 'html', entry + '.html')
        if not os.path.exists(path) and os.getenv('GRASS_ADDON_BASE'):
            path = os.path.join(os.getenv('GRASS_ADDON_BASE'), 'docs', 'html', entry + '.html')

        if not os.path.exists(path):
            grass.fatal(_("No HTML manual page entry for '%s'") % entry)

        url_path = 'file://' + path

    if browser and browser not in ('xdg-open', 'start'):
        webbrowser.register(browser_name, None)

    grass.verbose(_("Starting browser '%(browser)s' for manual"
                    " entry '%(entry)s'...") %
                  dict(browser=browser_name, entry=entry))

    try:
        webbrowser.open(url_path)
    except:
        grass.fatal(_("Error starting browser '%(browser)s' for HTML file"
                      " '%(path)s'") % dict(browser=browser, path=path))
Example #21
0
def repeat():
    tor_path = \
        'C:\\Users\\etern\\OneDrive\\Desktop\\Tor Browser\\Browser\\firefox.exe'
    webbrowser.register('tor', None, webbrowser.BackgroundBrowser(tor_path))
    webbrowser.get('tor').open(url)
    time.sleep(15)
    os.system("taskkill /im tor.exe /f")
def run():
    print('Memulai Services...')
    home = str(Path.home())
    dir_app = home + '\mysite'
    cmd_path = 'cmd /c "C: & cd {} & docker-compose start"'.format(dir_app)
    os.system(cmd_path)
    url = '127.0.0.1:8000'
    status = True
    while status:
        try:
            if requests.get('http://localhost:8000/').status_code == 200:
                try:
                    webbrowser.register(
                        'chrome', None,
                        webbrowser.BackgroundBrowser(
                            "C://Program Files (x86)//Google//Chrome//Application//chrome.exe"
                        ))
                    webbrowser.get('chrome').open(url)
                except Exception as e:
                    try:
                        webbrowser.register(
                            'firefox', None,
                            webbrowser.BackgroundBrowser(
                                "C://Program Files//Mozilla Firefox//firefox.exe"
                            ))
                        webbrowser.get('firefox').open(url)
                    except Exception as e:
                        webbrowser.open(url)
                status = False
        except ConnectionError as e:
            pass
Example #23
0
    def ask_translate(self):
        """Запрашиваем перевод этого слова"""
        self.translate = translation(self.word, "en")

        reply = QMessageBox.question(
            self, 'Мы все сделали за вас',
            f"Перевод этого слова на английский язык: {self.translate}",
            QMessageBox.Yes)

        self.word, self.translate = self.translate, self.word  # меняем их местами(так надо)
        if reply == QMessageBox.Yes:
            webbrowser.register(
                'Safari', None,
                webbrowser.BackgroundBrowser('/User/Desctop/Safari'))
            webbrowser.open_new_tab(
                f'https://www.google.com/search?q={self.word}&newwindow=1&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjp8sza_5jtAhXjwosKHbZ8BYQQ_AUoAnoECB4QBA&cshid=1606145893253510&biw=1280&bih=881'
            )
            self.load_image()
            self.translate = self.translate.strip()
        else:
            reply = QMessageBox.question(
                self, '', "Вы точно хотите вернуться шаг назад?",
                QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
            if reply == QMessageBox.Yes:
                self.ask_word()
            else:
                self.ask_translate()
Example #24
0
 def usr_show():
     chromePath = r'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
     webbrowser.register('chrome', None,
                         webbrowser.BackgroundBrowser(chromePath))
     file_name = 'F:\\pyspace\\Graduation project\\user_data\\' + str(
         user_id) + '_data.html'
     webbrowser.get('chrome').open_new_tab(file_name)
Example #25
0
 def initialize():
     '''
     Register chrome as a web browser to be used
     '''
     webbrowser.register(
         'chrome', None,
         webbrowser.BackgroundBrowser(
             "C://Program Files//Google//Chrome//Application//chrome.exe"))
Example #26
0
 def _init_local_visualization(self, event):
     import webbrowser
     if self._webbrower is not None:
         webbrowser.register('brower', None,
                             webbrowser.BackgroundBrowser(self._webbrower))
         webbrowser.get('brower').open(f'{self._host}:{self._port}',
                                       new=1,
                                       autoraise=True)
Example #27
0
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'))
Example #28
0
def openurl():

    url = "https://stu.chinahrt.com/index.html#/pharmacist/index"
    chromepath = "C://Program Files (x86)//Google//Chrome//Application//chrome.exe"

    webbrowser.register('chrome', None,
                        webbrowser.BackgroundBrowser(chromepath))
    webbrowser.get('chrome').open(url)
Example #29
0
 def __init__(self):
     super(CrackTaobao, self).__init__()
     self.url = 'https://reg.taobao.com/member/reg/fill_mobile.htm'
     self.succ_count = 0
     self.unsucc_count = 0
     self.chromepath = r"D:\\Google\Chrome\\Application\chrome.exe"
     webbrowser.register('chrome', None,
                         webbrowser.BackgroundBrowser(self.chromepath))
Example #30
0
 def open_url(self):
     url = self.table.selection_get()
     webbrowser.register(
         'chrome', None,
         webbrowser.BackgroundBrowser(
             "C://Users//awgra//AppData//Local//Google//Chrome//Application//chrome.exe"
         ))
     webbrowser.get('chrome').open(url)
Example #31
0
def use_firefox_open_url(url):
    browser_path = r'D:\Program Files (x86)\Mozilla Firefox\firefox.exe'
    #这里的‘firefox’只是一个浏览器的代号,可以命名为自己认识的名字,只要浏览器路径正确
    web.register('firefox', web.Mozilla('mozilla'),
                 web.BackgroundBrowser(browser_path))
    #web.get('firefox').open(url,new=1,autoraise=True)
    web.get('firefox').open_new_tab(url)
    print('use_firefox_open_url  open url ending ....')
Example #32
0
def access():
    """ Access KakaoTalk authentication server to get access code
    """
    url = 'https://kauth.kakao.com/oauth/authorize?client_id=' \
          + REST_API_KEY + '&redirect_uri=' + REDIRECT_URL \
          + '&response_type=code&scope=talk_message'
    webbrowser.register('firefox', None)
    webbrowser.open(url)
Example #33
0
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'))
Example #34
0
def web(url):
    webbrowser.register(
        'chrome', None,
        webbrowser.BackgroundBrowser(
            "C://Program Files (x86)//Google//Chrome//Application//chrome.exe")
    )

    webbrowser.get('chrome').open(url)
Example #35
0
def open_htmlcode_in_browser( html ) :
    import os , time , webbrowser
    tmp_file_name = "__temp__.html"
    webbrowser.register('firefox', None, webbrowser.GenericBrowser('firefox'), 1)
    with open( tmp_file_name , "w+" ) as f :
        f.write( html )
    webbrowser.get("firefox").open( "file://" + os.popen( "cygpath -w " + os.path.realpath( tmp_file_name ) ).read() )
    time.sleep( 2 ) 
 def open_url(self, url=None, browser_name=None):
     if not browser_name:
         webbrowser.open(url)
     else:
         browser_path = browser.get_path(browser_name)
         webbrowser.register(browser_name, None,
                             webbrowser.BackgroundBrowser(browser_path))
         webbrowser.get(browser_name).open_new_tab(url)
Example #37
0
def get_browser():
    browser_list = ['galeon', 'mozilla', 'lynx']
    for b in browser_list:
        if test_access( b):
            browser = webbrowser.GenericBrowser( b + ' %s')
            webbrowser.register( b, None, browser)
            return b
    print 'No Web browser found.'
    return ''
Example #38
0
  def openChrome(self):

    url = "http://localhost:9901/debug?port=5858"

    config = sublime.load_settings(SETTINGS_FILE)
    chrome_path = config.get('chrome_path',"")
    chrome = webbrowser.BackgroundBrowser(chrome_path)
    webbrowser.register('chrome', None, chrome)
    webbrowser.get('chrome').open_new_tab(url)
Example #39
0
def register_webbrowser_url_hook():
    """registers pythons webbrowser module as url_hook"""
    import webbrowser
    def open_url(d, link, data):
        webbrowser.open(link)
    if sys.platform.startswith("linux"):
        webbrowser.register("xdg-open", None,
                webbrowser.GenericBrowser('xdg-open'),  update_tryorder=-1)
    gtk.about_dialog_set_url_hook(open_url, None)
Example #40
0
    def run(self, edit):

        chromePath = 'D:\\Program\\Chrome\\chrome.exe'
        chromePath2 = 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
        if not os.path.isfile(chromePath):
            chromePath = chromePath2
        print(os.path.isfile(chromePath))
        webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(chromePath))
        webbrowser.get('chrome').open_new_tab(self.view.file_name())
Example #41
0
    def run(self):
        settings = context.get_toolingapi_settings()
        browser_path = settings["default_chrome_path"]

        plugin_url = "https://github.com/xjsender/SublimeApex#sublime-ide-for-salesforce"
        if os.path.exists(browser_path):
            webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(browser_path))
            webbrowser.get('chrome').open_new_tab(plugin_url)
        else:
            webbrowser.open_new_tab(plugin_url)
Example #42
0
    def open_documentation(self, index):
        if index == -1: return

        link = self.title_link[self.titles[index]]
        show_url= 'http://www.salesforce.com/us/developer/docs/%s%s' % (link["attr"], link["url"])
        settings = context.get_toolingapi_settings()
        browser_path = settings["default_chrome_path"]
        if os.path.exists(browser_path):
            webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(browser_path))
            webbrowser.get('chrome').open_new_tab(show_url)
        else:
            webbrowser.open_new_tab(show_url)
Example #43
0
    def test_register(self):
        webbrowser = support.import_fresh_module('webbrowser')
        self.assertIsNone(webbrowser._tryorder)
        self.assertFalse(webbrowser._browsers)

        class ExampleBrowser:
            pass
        webbrowser.register('Example1', ExampleBrowser)
        self.assertTrue(webbrowser._tryorder)
        self.assertEqual(webbrowser._tryorder[-1], 'Example1')
        self.assertTrue(webbrowser._browsers)
        self.assertIn('example1', webbrowser._browsers)
        self.assertEqual(webbrowser._browsers['example1'], [ExampleBrowser, None])
Example #44
0
def _credentials_flow_interactive(client_secrets_path):
    flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(
        client_secrets_path,
        scopes=[_ASSISTANT_OAUTH_SCOPE])
    if 'DISPLAY' in os.environ:
        # Use chromium-browser by default. Raspbian Stretch uses Epiphany by
        # default but that seems to cause issues:
        # https://github.com/google/aiyprojects-raspbian/issues/269
        webbrowser.register('chromium-browser', None, webbrowser.Chrome('chromium-browser'), -1)
        credentials = flow.run_local_server()
    else:
        credentials = flow.run_console()
    return credentials
def open_htmlcode_in_browser( html ) :
    import webbrowser 
    import os  
    import time
    # print html
    tmp_file_name = "__temp__.html"
    webbrowser.register('firefox', None, webbrowser.GenericBrowser('firefox'), 1)
    #print webbrowser._tryorder
    with open( tmp_file_name , "w+" ) as f :
        f.write( html )
    webbrowser.get("firefox").open( "file://" + os.popen( "cygpath -w " + os.path.realpath( tmp_file_name ) ).read() )
    # time.sleep( 2 ) 
    os.remove( tmp_file_name )
Example #46
0
 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)
Example #47
0
def OpenBroswer(appName,appPath):
	global __FILE_NAME__
	appName = ConvertString(appName)
	appPath = ConvertString(appPath)
	broswer = webbrowser.BackgroundBrowser(appPath)
	register = webbrowser.register(appName, None, broswer)
	soulteary = webbrowser.get(appName)
	if None != soulteary:
		soulteary.open(__FILE_NAME__)
Example #48
0
    def _check_registration(self, preferred):
        class ExampleBrowser:
            pass

        expected_tryorder = []
        expected_browsers = {}

        self.assertEqual(webbrowser._tryorder, expected_tryorder)
        self.assertEqual(webbrowser._browsers, expected_browsers)

        webbrowser.register('Example1', ExampleBrowser)
        expected_tryorder = ['Example1']
        expected_browsers['example1'] = [ExampleBrowser, None]
        self.assertEqual(webbrowser._tryorder, expected_tryorder)
        self.assertEqual(webbrowser._browsers, expected_browsers)

        instance = ExampleBrowser()
        if preferred is not None:
            webbrowser.register('example2', ExampleBrowser, instance,
                                preferred=preferred)
        else:
            webbrowser.register('example2', ExampleBrowser, instance)
        if preferred:
            expected_tryorder = ['example2', 'Example1']
        else:
            expected_tryorder = ['Example1', 'example2']
        expected_browsers['example2'] = [ExampleBrowser, instance]
        self.assertEqual(webbrowser._tryorder, expected_tryorder)
        self.assertEqual(webbrowser._browsers, expected_browsers)
Example #49
0
 def open_browser():
     url = "http://localhost:%d/rss_reader.html?search=%s" % (port, period)
     if fLOG:
         fLOG("opening ", url)
     if browser is not None:
         if browser in ["none", "None"]:
             pass
         else:
             try:
                 b = webbrowser.get(browser)
             except webbrowser.Error as e:
                 if browser == "firefox" and sys.platform.startswith("win"):
                     webbrowser.register(
                         'firefox',
                         None,
                         webbrowser.GenericBrowser(r"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"))
                     b = webbrowser.get(browser)
                 else:
                     raise e
             b.open(url)
     else:
         webbrowser.open(url)
Example #50
0
    def run(self, startURL=""):
        # Get toolingapi settings
        settings = context.get_toolingapi_settings()

        # Combine Login URL
        show_params = {
            "un": settings["username"],
            "pw": settings["password"],
            "startURL": startURL
        }

        if util.is_python3x():
            show_params = urllib.parse.urlencode(show_params)
        else:
            show_params = urllib.urlencode(show_params)

        show_url = settings["login_url"] + '?%s' % show_params

        browser_path = settings["default_chrome_path"]
        if os.path.exists(browser_path):
            webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(browser_path))
            webbrowser.get('chrome').open_new_tab(show_url)
        else:
            webbrowser.open_new_tab(show_url)
Example #51
0
    def mkbrowseto(self, url):
        """Create the urwid callback function to open the web browser or call
        another function with the URL.

        """
        # Try-except block to work around webbrowser module bug
        # https://bugs.python.org/issue31014
        try:
            browser = os.environ['BROWSER']
        except KeyError:
            pass
        else:
            del os.environ['BROWSER']
            webbrowser.register(browser, None, webbrowser.GenericBrowser(browser))
            try_idx = webbrowser._tryorder.index(browser)
            webbrowser._tryorder.insert(0, webbrowser._tryorder.pop(try_idx))

        def browse(*args):
            # double ()() to ensure self.search evaluated at runtime, not when
            # browse() is _created_. [0] is self.search, [1] is self.enter
            # self.enter prevents opening URL when in search mode
            if self._get_search()[0]() is True:
                if self._get_search()[1]() is True:
                    self.search = False
                    self.enter = False
            elif not self.run:
                webbrowser.open(url)
            elif self.run and self.pipe:
                process = Popen(shlex.split(self.run), stdout=PIPE, stdin=PIPE)
                process.communicate(input=url.encode(sys.getdefaultencoding()))
            else:
                Popen(self.run.format(url), shell=True).communicate()

            size = self.tui.get_cols_rows()
            self.draw_screen(size)
        return browse
Example #52
0
 def test_synthesize(self):
     webbrowser = support.import_fresh_module('webbrowser')
     name = os.path.basename(sys.executable).lower()
     webbrowser.register(name, None, webbrowser.GenericBrowser(name))
     webbrowser.get(sys.executable)
Example #53
0
    def __init__(self, server=None, palette='default',
                 keymap='default', debug=False, verbose=False,
                 disable_sync=False, disable_background_sync=False,
                 fetch_missing_refs=False,
                 path=config.DEFAULT_CONFIG_PATH):
        self.server = server
        self.config = config.Config(server, palette, keymap, path)
        if debug:
            level = logging.DEBUG
        elif verbose:
            level = logging.INFO
        else:
            level = logging.WARNING
        logging.basicConfig(filename=self.config.log_file, filemode='w',
                            format='%(asctime)s %(message)s',
                            level=level)
        # Python2.6 Logger.setLevel doesn't convert string name
        # to integer code. Here, we set the requests logger level to
        # be less verbose, since our logging output duplicates some
        # requests logging content in places.
        req_level_name = 'WARN'
        req_logger = logging.getLogger('requests')
        if sys.version_info < (2, 7):
            level = logging.getLevelName(req_level_name)
            req_logger.setLevel(level)
        else:
            req_logger.setLevel(req_level_name)
        self.log = logging.getLogger('gertty.App')
        self.log.debug("Starting")

        self.project_cache = ProjectCache()
        self.ring = mywid.KillRing()
        self.input_buffer = []
        webbrowser.register('xdg-open', None, BackgroundBrowser("xdg-open"))

        self.fetch_missing_refs = fetch_missing_refs
        self.config.keymap.updateCommandMap()
        self.search = search.SearchCompiler(self.config.username)
        self.db = db.Database(self, self.config.dburi, self.search)
        self.sync = sync.Sync(self, disable_background_sync)

        self.status = StatusHeader(self)
        self.header = urwid.AttrMap(self.status, 'header')
        self.screens = urwid.MonitoredList()
        self.breadcrumbs = BreadCrumbBar()
        self.screens.set_modified_callback(
            functools.partial(self.breadcrumbs._update, self.screens))
        if self.config.breadcrumbs:
            self.footer = urwid.AttrMap(self.breadcrumbs, 'footer')
        else:
            self.footer = None
        screen = view_project_list.ProjectListView(self)
        self.status.update(title=screen.title)
        self.updateStatusQueries()
        self.frame = urwid.Frame(body=screen, footer=self.footer)
        self.loop = urwid.MainLoop(self.frame, palette=self.config.palette.getPalette(),
                                   handle_mouse=self.config.handle_mouse,
                                   unhandled_input=self.unhandledInput,
                                   input_filter=self.inputFilter)

        self.sync_pipe = self.loop.watch_pipe(self.refresh)
        self.error_queue = queue.Queue()
        self.error_pipe = self.loop.watch_pipe(self._errorPipeInput)
        self.logged_warnings = set()
        self.command_pipe = self.loop.watch_pipe(self._commandPipeInput)
        self.command_queue = queue.Queue()

        warnings.showwarning = self._showWarning

        has_subscribed_projects = False
        with self.db.getSession() as session:
            if session.getProjects(subscribed=True):
                has_subscribed_projects = True
        if not has_subscribed_projects:
            self.welcome()

        self.loop.screen.tty_signal_keys(start='undefined', stop='undefined')
        #self.loop.screen.set_terminal_properties(colors=88)

        self.startSocketListener()

        if not disable_sync:
            self.sync_thread = threading.Thread(target=self.sync.run, args=(self.sync_pipe,))
            self.sync_thread.daemon = True
            self.sync_thread.start()
        else:
            self.sync_thread = None
            self.sync.offline = True
            self.status.update(offline=True)
Example #54
0
if sys.platform[:3] == 'win':
  import _winreg
  
  # We don't want to load this class by default, because Python 2.4 doesn't have BaseBrowser.
  
  class WindowsHttpDefault(webbrowser.BaseBrowser):
    """Provide an alternate open class for Windows user, using the http handler."""

    def open(self, url, new=0, autoraise=1):
      command_args = create_win32_http_cmd(url)
      if not command_args:
        output('$ Could not find HTTP handler')
        return False

      output('command_args:')
      output(command_args)
      # Avoid some unicode path issues by moving our current directory
      old_pwd = os.getcwd()
      os.chdir('C:\\')
      try:
        _unused = subprocess.Popen(command_args)
        os.chdir(old_pwd)
        return True
      except:
        traceback.print_exc()
        output('$ Failed to run HTTP handler, trying next browser.')
        os.chdir(old_pwd)
        return False

  webbrowser.register('windows-http', WindowsHttpDefault, update_tryorder=-1)
Example #55
0
 def register(pathname, key):
     webbrowser._tryorder += [key]
     webbrowser.register(key, None, webbrowser.GenericBrowser("%s '%%s'" % pathname))
Example #56
0
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:
            webbrowser._tryorder.insert(len(os.environ['BROWSER'].split(os.pathsep)), 'kfmclient')
Example #57
0
import os, sys, threading, webbrowser
from quixote.directory import Directory
from quixote.session import Session, SessionManager
from quixote.server import simple_server
from quixote.errors import AccessError
from quixote.form.form import Form
from quixote.form.widget import StringWidget, PasswordWidget, SubmitWidget
from quixote import get_response, get_user, get_session
from quixote.publish import Publisher
from quixote.html import href, htmltext

################## PUBLICATION MACHINERY ###########################

elinks = webbrowser.GenericBrowser('xterm -e elinks %s')
lynx = webbrowser.GenericBrowser('xterm -e lynx -accept_all_cookies %s') 
webbrowser.register("elinks", webbrowser.GenericBrowser, elinks)
webbrowser.register("lynx", webbrowser.GenericBrowser, lynx) # second choice
webbrowser.register("konqueror", webbrowser.Konqueror)

class Publish(object):
    def __init__(self, root, Publisher=Publisher, Session=Session,
                 session_mapping=None, server=simple_server,
                 showpage=None, browser="mozilla", host='', port=7080):
        self.root = root
        self.Publisher = Publisher
        self.Session = Session
        self.session_mapping = session_mapping
        self.server = server
        self.host = host
        self.port = port
        self.showpage = showpage
Example #58
0
s_config = cm_config_server()


with_browser = s_config.get("cloudmesh.server.webui.browser")
browser_page = s_config.get("cloudmesh.server.webui.page")
host = s_config.get("cloudmesh.server.webui.host")
port = s_config.get("cloudmesh.server.webui.port")

# load home page if no page specified
if browser_page:
    url_link = "http://{0}:{1}/{2}".format(host, port, browser_page)
else:
    url_link = "http://{0}:{1}".format(host, port)

webbrowser.register("safari", None)


# from cloudmesh.util.webutil import setup_imagedraw

with_rack = s_config.get("cloudmesh.server.rack.with_rack")

try:
    import matplotlib
    all_modules.append('rack')
    all_modules.append('metric')
    
except:
    log.info("The Rack diagrams are not enabled")

# exclude_modules = ['flatpages']
Example #59
0
def run_browser(url):
	webbrowser.register('open', webbrowser.GenericBrowser("open '%s'"))
	webbrowser._tryorder.append('open')
	webbrowser.open(url)