示例#1
0
 def f(i):
     try:
         uri = "https://{}".format(i.addresses["https"])
     except KeyError:
         uri = "http://{}".format(i.addresses["http"])
     log.info("Opening web browser for machine %r at %r", i.fq_name,
              uri)
     open_browser(uri)
示例#2
0
 def popup():
     try:
         # see <https://github.com/jupyter/notebook/issues/3746#issuecomment-444957821>
         # if this doesn't happen on MacOS
         from webbrowser import open as open_browser
         open_browser(my_url)
     except:
         logging.error("Unable to pop browser open", exc_info=1)
示例#3
0
def browse(query):
    try:
        url = "https://www.google.com.tr/search?q={}".format(query)
        open_browser(url)
        print("Search has been made")
        return True

    except Exception as e:
        print('Exception thrown in browse() ' + str(e))
        return False
示例#4
0
文件: wizard.py 项目: refaim/wots
 def editorEvent(self, event, model, option, index):
     if event.type() == QtCore.QEvent.MouseButtonRelease:
         url = index.data(QtCore.Qt.ToolTipRole)
         VISITED_URLS.add(url)
         url = url.replace('https://', 'http://')
         if not url.startswith('http://'):
             url = 'http://{0}'.format(url)
         open_browser(url)
         return True
     return False
示例#5
0
def main(args: Namespace):
    """
    Main function for calling the API from the package depending on
    the CLI options.
    """
    # pylint: disable=too-many-branches
    ctx = Context(args)

    print_logo(ctx)

    if ctx.quiet:
        set_log_levels(logging.NOTSET)
    elif 0 < ctx.verbose <= 1:
        set_log_levels(logging.WARNING)
    elif 1 < ctx.verbose <= 2:
        set_log_levels(logging.INFO)
    elif ctx.verbose > 2:
        set_log_levels(logging.DEBUG)

    LOG.info('Setting up default logging level to %s', LOG.level)
    LOG.debug('CLI args: %s', args)
    LOG.debug('Context: %s', vars(ctx))

    hasher = ctx.hasher

    # actions
    if ctx.files:
        for file in ctx.files:
            print(hash_file(path=file, hasher=hasher))
    elif ctx.traverse:
        for folder in ctx.traverse:
            print(find_files(ctx=ctx, folder=folder))
    elif ctx.hash:
        found_lists = [
            find_files(ctx=ctx, folder=folder)
            for folder in ctx.hash
        ]
        print(filter_files(hash_files(files=[
            file
            for file_list in found_lists
            for file in file_list
        ], hasher=hasher)))
    elif ctx.duplicates:
        handle_duplicates(ctx=ctx, hasher=hasher)
    elif ctx.version:
        print(VERSION)
    elif ctx.community:
        open_browser(COMMUNITY_URL)
    elif ctx.load_hashes:
        if not ctx.hashfiles:
            ctx.hashfiles = ctx.load_hashes
        load_hashes(ctx=ctx)
示例#6
0
def main():
    if 'list' in args.url:
        args.url = args.url.split("&list=")[0]

    if "?v=" in args.url:
        video_code = args.url.split('?v=')[1]
    elif "youtu.be" in args.url:
        vider_cdeo = args.url.split('youtu.be/')[1]
    video_url = f"https://www.dideo.ir/v/yt/{video_code}/"
    print(video_url)
    if CheckUrl(video_url) and args.open:
        open_browser(video_url)
    if args.download and CheckUrl(video_url):
        DownloadVideo(video_url)
示例#7
0
    def __make_root_menu(self):
        """Creates the top bar menu with saving/loading, various settings etc."""
        root_menu = Menu(self, tearoff=0)
        settings_menu = Menu(root_menu, tearoff=0)
        root_menu.add_cascade(label='Settings', menu=settings_menu)
        root_menu.add_command(
            label='About',
            command=lambda: open_browser('https://github.com/cernyd/enigma'))

        # CONFIGURATION MENU
        config_menu = Menu(settings_menu, tearoff=0)

        config_menu.add_command(label='Save Configuration',
                                command=self.save_config)
        config_menu.add_command(label='Load Configuration',
                                command=self.load_config)
        config_menu.add_command(label='Delete Configuration',
                                command=self.data_handler.remove_config)

        # SAVING AND LOADING
        settings_menu.add_cascade(label='Saving and Loading', menu=config_menu)

        settings_menu.add_separator()
        settings_menu.add_checkbutton(label='Enable sound',
                                      variable=self._sound_enabled)
        settings_menu.add_checkbutton(label='Autorotate',
                                      variable=self._autorotate)
        settings_menu.add_checkbutton(label='Rotor lock',
                                      variable=self._rotor_lock)
        settings_menu.add_checkbutton(label='Synchronised scrolling',
                                      variable=self._sync_scroll)
        settings_menu.add_checkbutton(label='Numbers on rotor indicators',
                                      variable=self._show_numbers)
        settings_menu.add_separator()

        # ENIGMA RESET AND MODEL SETTINGS
        enigma_model_menu = Menu(settings_menu, tearoff=0)

        # Current model var, must add some indication of current model into the enigma
        self.current_model = StringVar(
            value=self.data_handler.enigma.factory_data['model'])
        for model in self.data_handler.enigma_factory.all_models():
            enigma_model_menu.add_radiobutton(label=model,
                                              variable=self.current_model)
        self.current_model.trace('w', self.hard_reset)
        settings_menu.add_cascade(label='Enigma model', menu=enigma_model_menu)
        settings_menu.add_command(label='Reset all', command=self.hard_reset)

        self.config(menu=root_menu)
示例#8
0
 def f(m):
     click.echo("Opening web browser for machine {!r} at "
                "«{}»".format(m.spec.fq_name, m.spec.http_uri))
     open_browser(m.spec.http_uri)
示例#9
0
 def f(m):
     http_uri = m.uri("http")
     click.echo("Opening web browser for machine {!r} at "
                "«{}»".format(m.spec.fq_name, http_uri))
     open_browser(http_uri)
示例#10
0
 def show_trailer(self):
     """
     Opens a browser to show the youtube trailer for the movie.
     :return: nothing
     """
     open_browser(self.trailer_youtube_url)
# https://mail.google.com/mail/?view=cm&fs=1&[email protected]&su=SUBJECT&body=BODY&[email protected]

from urllib.parse import urlencode
from webbrowser import open as open_browser

TO_EMAIL = "*****@*****.**"
SUBJECT = "My Subject line"
BODY = "My body line"

url_parameters = urlencode(
    dict(view='cm', fs='1', to=TO_EMAIL, su=SUBJECT, body=BODY))
email_compose_url = f"https://mail.google.com/mail/?{url_parameters}"
open_browser(email_compose_url)
示例#12
0
文件: define.py 项目: hph/def
def bug_report():
    '''Ask user and open a new issue on github.'''
    response = raw_input('This may be a bug. Report issue (yes/no)?\n')
    if response in ['Y', 'YES', 'Yes', 'y', 'yes']:
        open_browser('https://github.com/haukurpallh/def/issues/new')
示例#13
0
import logging

from flask import Flask, render_template
from webbrowser import open as open_browser

FB_OATH_URL = 'https://www.facebook.com/v2.6/dialog/oauth?redirect_uri=http%3A%2F%2Flocalhost%3A5000&state=%7B%22challenge%22%3A%22q1WMwhvSfbWHvd8xz5PT6lk6eoA%253D%22%2C%220_auth_logger_id%22%3A%2254783C22-558A-4E54-A1EE-BB9E357CC11F%22%2C%22com.facebook.sdk_client_state%22%3Atrue%2C%223_method%22%3A%22sfvc_auth%22%7D&scope=user_birthday%2Cuser_photos%2Cuser_education_history%2Cemail%2Cuser_relationship_details%2Cuser_friends%2Cuser_work_history%2Cuser_likes&response_type=token%2Csigned_request&default_audience=friends&return_scopes=true&auth_type=rerequest&client_id=464891386855067&ret=login&sdk=ios&logger_id=54783C22-558A-4E54-A1EE-BB9E357CC11F#_=_'

logger = logging.getLogger(__name__)
app = Flask(__name__)


@app.route('/')
def home():
    return render_template('index.html')


if __name__ == '__main__':
    open_browser(FB_OATH_URL, new=2)
    app.run(port=5000)