Exemplo n.º 1
0
def main():
    """Initialize application."""
    import pyotherside
    conf.read()
    pyotherside.atexit(conf.write)
    global app
    app = Application()
Exemplo n.º 2
0
    def __init__(self, m, d, i):
        GUIModule.__init__(self, m, d, i)

        # some constants
        self.msLongPress = 400
        self.centeringDisableThreshold = 2048
        self.firstTimeSignal = signal.Signal()
        size = (800, 480) # initial window size

        # register exit handler
        pyotherside.atexit(self._shutdown)

        # window state
        self._fullscreen = False

        # get screen resolution
        # TODO: implement this
        #screenWH = self.getScreenWH()
        #print(" @ screen size: %dx%d" % screenWH)
        #if self.highDPI:
        #    print(" @ high DPI")
        #else:
        #    print(" @ normal DPI")

        # NOTE: what about multi-display devices ? :)

        ## add image providers

        self._imageProviders = {
            "icon" : IconImageProvider(self),
            "tile" : TileImageProvider(self),
        }

        with open("data/tile_not_found.png", "rb") as f:
            self._tileNotFoundImage = f.read()

        ## register the actual callback, that
        ## will call the appropriate provider base on
        ## image id prefix
        pyotherside.set_image_provider(self._selectImageProviderCB)

        # initialize theming
        self._theme = Theme(self)

        ## make constants accessible
        #self.constants = self.getConstants()
        #rc.setContextProperty("C", self.constants)

        ## connect to the close event
        #self.window.closeEvent = self._qtWindowClosed
        ##self.window.show()

        self._notificationQueue = []

        # provides easy access to modRana modules from QML
        self.modules = Modules(self)

        # search functionality for the QML context
        self.search = Search(self)
Exemplo n.º 3
0
def start_seren():
    """ Run Seren without ncurses and connect pipes """
    username = getpass.getuser()
    seren = subprocess.Popen(
        shlex.split('seren -N'),
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT,
    )
    global stdin
    stdin = seren.stdin
    pyotherside.atexit(lambda: kill(seren))
    _thread.start_new_thread(read_output, (seren.stdout,))
    pyotherside.send('node-join', datetime.datetime.now(),
                     html.escape(username), '127.0.0.1:8110')
Exemplo n.º 4
0
def start_seren():
    """ Run Seren without ncurses and connect pipes """
    username = getpass.getuser()
    seren = subprocess.Popen(
        shlex.split('seren -N'),
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT,
    )
    global stdin
    stdin = seren.stdin
    pyotherside.atexit(lambda: kill(seren))
    _thread.start_new_thread(read_output, (seren.stdout, ))
    pyotherside.send('node-join', datetime.datetime.now(),
                     html.escape(username), '127.0.0.1:8110')
Exemplo n.º 5
0
        self.filename = os.path.expanduser('~/pyotherside_notes.txt')
        self.thread = None
        self.new_text = self.get_contents()

    def save_now(self):
        print('Saving file right away at exit')
        self._update_file(now=True)

    def _update_file(self, now=False):
        if not now:
            time.sleep(3)
        print('Saving file now')
        open(self.filename, 'w').write(self.new_text)
        self.thread = None

    def get_contents(self):
        if os.path.exists(self.filename):
            return open(self.filename).read()
        else:
            return '<new file>'

    def set_contents(self, text):
        self.new_text = text
        if self.thread is None:
            print('Scheduling saving of file')
            self.thread = threading.Thread(target=self._update_file)
            self.thread.start()

notes = Notes()
pyotherside.atexit(notes.save_now)
Exemplo n.º 6
0
    client = hangups.Client(cookies)
    print("Adding client observer")
    client.on_connect.add_observer(on_connect)

    loop = asyncio.get_event_loop()

    t = threading.Thread(target=run_asyncio_loop_in_thread, args=(loop, ))
    t.start()


def start():
    # Authenticate and connect
    try:
        auth_with_token()
    except requests.exceptions.ConnectionError as e:
        error_title = e.args[0].args[0]
        error_description = e.args[0].args[1]
        pyotherside.send('show-network-error', "ConnectionError", error_title,
                         str(error_description))


def on_quit():
    print("Exiting ...")
    print('Saving settings ...')
    settings.save()
    client.disconnect()
    loop.close()


pyotherside.atexit(on_quit)
Exemplo n.º 7
0
# This examples shows how to do cleanups and other things when
# the application exists by using pyside.atexit().

import pyotherside

def called_when_exiting():
    print('Now exiting the application...')

pyotherside.atexit(called_when_exiting)
print('python loaded')
Exemplo n.º 8
0
            return p.name == provider

        for provider in registry.directory.select(match_provider):
            return [{
                'title': e.title,
                'url': e.url,
                'image': e.image,
                'subscribers': e.subscribers,
                'description': e.description,
            } for e in provider.on_string(query)]

        return []


gpotherside = gPotherSide()
pyotherside.atexit(gpotherside.atexit)

pyotherside.send('hello', gpodder.__version__, __version__,
                 podcastparser.__version__)

# Exposed API Endpoints for calls from QML
initialize = gpotherside.initialize
load_podcasts = gpotherside.load_podcasts
load_episodes = gpotherside.load_episodes
show_episode = gpotherside.show_episode
play_episode = gpotherside.play_episode
subscribe = gpotherside.subscribe
unsubscribe = gpotherside.unsubscribe
check_for_episodes = gpotherside.check_for_episodes
get_stats = gpotherside.get_stats
get_fresh_episodes_summary = gpotherside.get_fresh_episodes_summary
Exemplo n.º 9
0
# This examples shows how to do cleanups and other things when
# the application exists by using pyside.atexit().

import pyotherside


def called_when_exiting():
    print('Now exiting the application...')


pyotherside.atexit(called_when_exiting)
print('python loaded')
Exemplo n.º 10
0
                    # and no output is buffered <-- timeout + dead subprocess
                    assert not select([master], [], [], 0)[0] # race is possible
                    os.close(slave_fd) # subproces don't need it anymore
                    break
    rc = process.wait()
    print("subprocess exited with status %d" % rc)
    processs.kill()

def init(import_trace, import_plugins):
    global trace
    trace = import_trace
    global plugins
    plugins = import_plugins
    global bgthread
    bgthread = Thread(target=run_process)
    return "created"


def start_proc():
    bgthread.start()
    return "started"


def kill():
    os.kill(process.pid, signal.SIGTERM)
    process.wait()
    bgthread = None
    return "stopperd"

pyotherside.atexit(kill)
Exemplo n.º 11
0
                                outer_style=outer_style, inner_style=inner_style)
    svg = re.sub(r'[{]([^}]+)[}]', expression, PILL_TEMPLATE)
    return bytearray(svg.encode('utf-8')), (width, height), pyotherside.format_data


@pyotherside.set_image_provider
def gpotherside_image_provider(image_id, requested_size):
    provider, args = image_id.split('/', 1)
    if provider == 'pill':
        return pill_image_provider(args, requested_size)

    raise ValueError('Unknown provider: %s' % (provider,))


gpotherside = gPotherSide()
pyotherside.atexit(gpotherside.atexit)

pyotherside.send('hello', gpodder.__version__, __version__, podcastparser.__version__)

# Exposed API Endpoints for calls from QML
initialize = gpotherside.initialize
load_podcasts = gpotherside.load_podcasts
load_episodes = gpotherside.load_episodes
show_episode = gpotherside.show_episode
play_episode = gpotherside.play_episode
subscribe = gpotherside.subscribe
unsubscribe = gpotherside.unsubscribe
check_for_episodes = gpotherside.check_for_episodes
get_stats = gpotherside.get_stats
get_fresh_episodes_summary = gpotherside.get_fresh_episodes_summary
download_episode = gpotherside.download_episode
Exemplo n.º 12
0
    print("Creating client ...")
    client = hangups.Client(cookies)
    print("Adding client observer")
    client.on_connect.add_observer(on_connect)

    loop = asyncio.get_event_loop()

    t = threading.Thread(target=run_asyncio_loop_in_thread, args=(loop,))
    t.start()


def start():
    # Authenticate and connect
    try:
        auth_with_token()
    except requests.exceptions.ConnectionError as e:
        error_title = e.args[0].args[0]
        error_description = e.args[0].args[1]
        pyotherside.send('show-network-error', "ConnectionError", error_title, str(error_description))


def on_quit():
    print("Exiting ...")
    print('Saving settings ...')
    settings.save()
    client.disconnect()
    loop.close()


pyotherside.atexit(on_quit)
Exemplo n.º 13
0
        if remote:
            # Run `socat readline tcp:127.0.0.1:4444` in a terminal to connect
            import remote_pdb
            remote_pdb.RemotePdb("127.0.0.1", 4444).set_trace()
        else:
            import pdb
            pdb.set_trace()

    def exit(self) -> None:
        try:
            asyncio.run_coroutine_threadsafe(
                self.backend.terminate_clients(),
                self._loop,
            ).result()
        except Exception as e:  # noqa
            print(e)


# The AppImage AppRun script overwrites some environment path variables to
# correctly work, and sets RESTORE_<name> equivalents with the original values.
# If the app is launched from an AppImage, now restore the original values
# to prevent problems like QML Qt.openUrlExternally() failing because
# the external launched program is affected by our AppImage-specific variables.
for var in ("LD_LIBRARY_PATH", "PYTHONHOME", "PYTHONUSERBASE"):
    if f"RESTORE_{var}" in os.environ:
        os.environ[var] = os.environ[f"RESTORE_{var}"]

BRIDGE = QMLBridge()

pyotherside.atexit(BRIDGE.exit)
Exemplo n.º 14
0
                pyotherside.send(
                    'onLoad',
                    "uhm... seems like this site does not exist, it might also be bug <br> ¯\_( ͡❛ ͜ʖ ͡❛)_/¯"
                )
            return

        try:

            gemsite = self.get_site(url)

            if gemsite is None:
                return

            gemsite = self.instert_html_links(gemsite,
                                              self.get_links(gemsite, url))
            self.cache_page(url, gemsite)

            pyotherside.send('onLoad', gemsite, scroll_height)
        except Exception as e:
            print("Error:", e)
            pyotherside.send(
                'onLoad',
                "uhm... seems like this site does not exist, it might also be bug <br> ¯\_( ͡❛ ͜ʖ ͡❛)_/¯"
            )

        return


gemini = Gemini()
pyotherside.atexit(gemini.save_data)
Exemplo n.º 15
0
        })
        gameMap[int(row["id"])] = games[-1]

    version_group_id = gameMap[game]["version_group_id"]
    log(f"preferred_language_id: {preferred_language_id}")
    log(f"version_group_id: {version_group_id}")
    return (loadPokédex(pokédex), pokédexes, pokédex, games, game
            )  #1: hardcoded reference to the national dex


def save():
    pass
    # saveBeforeExit()


def saveBeforeExit():
    global CONFIG_PATH
    global game
    global pokédex
    log("Exiting...")
    if not os.path.exists(CONFIG_DIR):
        os.makedirs(CONFIG_DIR)

    config = configparser.ConfigParser()
    config["DEFAULT"] = {"game": game, "pokédex": pokédex}
    with open(CONFIG_PATH, "w") as configFile:
        config.write(configFile)


pyotherside.atexit(saveBeforeExit)
Exemplo n.º 16
0
        self.filename = os.path.expanduser('~/pyotherside_notes.txt')
        self.thread = None
        self.new_text = self.get_contents()

    def save_now(self):
        print('Saving file right away at exit')
        self._update_file(now=True)

    def _update_file(self, now=False):
        if not now:
            time.sleep(3)
        print('Saving file now')
        open(self.filename, 'w').write(self.new_text)
        self.thread = None

    def get_contents(self):
        if os.path.exists(self.filename):
            return open(self.filename).read()
        else:
            return '<new file>'

    def set_contents(self, text):
        self.new_text = text
        if self.thread is None:
            print('Scheduling saving of file')
            self.thread = threading.Thread(target=self._update_file)
            self.thread.start()

notes = Notes()
pyotherside.atexit(notes.save_now)