コード例 #1
0
ファイル: gstreamer.py プロジェクト: marietje/maried
 def do_imports(self):
     global gi, gst, gobject
     import gi as _gi
     _gi.require_version('Gst', '1.0')
     from gi.repository import GObject as _gobject
     from gi.repository import Gst as _gst
     gst, gobject, gi = _gst, _gobject, _gi
コード例 #2
0
    def __convert_logo(self, destdir, package, logo_name):
        source_logo = os.path.join(destdir,
                self.packaging.substitute(package.install_to, package.name),
                logo_name)

        try:
            import gi
            gi.require_version('GdkPixbuf', '2.0')
            from gi.repository import GdkPixbuf
        except:
            logger.warning('Unable to load GdkPixbuf bindings. %s icon '
                    'will not be resized or converted' % self.game.longname)
            return

        mkdir_p(os.path.join(destdir, 'usr', 'share', 'icons',
                'hicolor', '48x48', 'apps'))
        mkdir_p(os.path.join(destdir, 'usr', 'share', 'icons',
                'hicolor', '256x256', 'apps'))

        pixbuf = GdkPixbuf.Pixbuf.new_from_file(source_logo)
        pixbuf.savev(os.path.join(destdir, 'usr', 'share', 'icons',
                    'hicolor', '256x256', 'apps', self.game.shortname + '.png'),
                'png', [], [])

        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(source_logo, 48, 48)
        pixbuf.savev(os.path.join(destdir, 'usr', 'share', 'icons',
                    'hicolor', '48x48', 'apps', self.game.shortname + '.png'),
                'png', [], [])
コード例 #3
0
def main():
    if len(sys.argv) < 3:
        exit("Usage: {0} <url> <quality>".format(sys.argv[0]))

    gi.require_version("Gst", "1.0")
    gobject.threads_init()
    gst.init(None)

    url = sys.argv[1]
    quality = sys.argv[2]

    livestreamer = Livestreamer()

    livestreamer.set_loglevel("info")
    livestreamer.set_logoutput(sys.stdout)

    try:
        streams = livestreamer.streams(url)
    except NoPluginError:
        exit("Livestreamer is unable to handle the URL '{0}'".format(url))
    except PluginError as err:
        exit("Plugin error: {0}.".format(err))

    if not streams:
        exit("No streams found on URL '{0}'.".format(url))

    if quality not in streams:
        exit("Unable to find '{0}' stream on URL '{1}'".format(quality, url))

    stream = streams[quality]

    player = LivestreamerPlayer()

    player.play(stream)
コード例 #4
0
ファイル: pygtkcompat.py プロジェクト: GNOME/pygobject
def enable_gudev():
    if _check_enabled("gudev"):
        return

    gi.require_version('GUdev', '1.0')
    from gi.repository import GUdev
    _patch_module('gudev', GUdev)
コード例 #5
0
ファイル: GUI.py プロジェクト: az0/bleachbit
    def worker_done(self, worker, really_delete):
        """Callback for when Worker is done"""
        self.progressbar.set_text("")
        self.progressbar.set_fraction(1)
        self.progressbar.set_text(_("Done."))
        self.textview.scroll_mark_onscreen(self.textbuffer.get_insert())
        self.set_sensitive(True)

        # Close the program after cleaning is completed.
        # if the option is selected under preference.

        if really_delete:
            if options.get("exit_done"):
                sys.exit()

        # notification for long-running process
        elapsed = (time.time() - self.start_time)
        logger.debug('elapsed time: %d seconds', elapsed)
        if elapsed < 10 or self.is_active():
            return
        try:
            import gi
            gi.require_version('Notify', '0.7')
            from gi.repository import Notify
        except:
            logger.debug('Notify not available')
        else:
            if Notify.init(APP_NAME):
                notify = Notify.Notification.new('BleachBit', _("Done."), 'bleachbit')
                if 'posix' == os.name and bleachbit.expanduser('~') == '/root':
                    notify.set_hint("desktop-entry", "bleachbit-root")
                else:
                    notify.set_hint("desktop-entry", "bleachbit")
                notify.show()
                notify.set_timeout(10000)
コード例 #6
0
ファイル: base_parser.py プロジェクト: mathijs-dumon/PyXRD
 def setup_file_filter(cls):
     """
         Creates a file filter based on a list of extensions set in the
         'extensions' attribute of the class using the 'description' attribute
         as the name for the filter. If the 'mimetypes' attribute is also set,
         it will also set these. If additional properties are needed, this function
         should be overriden by subclasses.
     """
     if cls.file_filter == None and cls.description != "" and cls.extensions:
         try:
             import gi
             gi.require_version('Gtk', '3.0')
             from gi.repository import Gtk
         except ImportError:
             pass
         else:
             # Init file filter:
             cls.file_filter = Gtk.FileFilter()
             cls.file_filter.set_name(cls.description)
             for mtpe in cls.mimetypes:
                 # cls.file_filter.add_mime_type(mtpe)
                 pass
             for expr in cls.extensions:
                 cls.file_filter.add_pattern(expr)
             setattr(cls.file_filter, "parser", cls)
コード例 #7
0
ファイル: __init__.py プロジェクト: evol262/anaconda
    def _on_spoke_clicked(self, selector, event, spoke):
        gi.require_version("Gdk", "3.0")
        from gi.repository import Gdk

        # This handler only runs for these two kinds of events, and only for
        # activate-type keys (space, enter) in the latter event's case.
        if event and not event.type in [Gdk.EventType.BUTTON_PRESS, Gdk.EventType.KEY_RELEASE]:
            return

        if event and event.type == Gdk.EventType.KEY_RELEASE and \
           event.keyval not in [Gdk.KEY_space, Gdk.KEY_Return, Gdk.KEY_ISO_Enter, Gdk.KEY_KP_Enter, Gdk.KEY_KP_Space]:
            return

        if selector:
            selector.grab_focus()

        # On automated kickstart installs, our desired behavior is to display
        # the hub while background processes work, then skip to the progress
        # hub immediately after everything's done.
        # However if the user proves his intent to change the kickstarted
        # values by entering any of the spokes, we need to disable the
        # autoContinue feature and wait for the user to explicitly state
        # that he is done configuring by pressing the continue button.
        self._autoContinue = False

        # Enter the spoke
        self._inSpoke = True
        spoke.entry_logger()
        spoke.refresh()
        self.main_window.enterSpoke(spoke)
コード例 #8
0
ファイル: engines.py プロジェクト: MSA-Argentina/zaguan
    def create_browser(debug=False, cache_model=None, process_model=None):
        """Creates a WebView instance, properly configured.

        Arguments:
            debug -- boolean to indicate if it should output debug and add
                context menu and inspector.
        """
        gi.require_version('WebKit', '3.0')
        from gi.repository.WebKit import WebView, WebSettings, set_cache_model

        if debug:
            WebKitMethods.print_version()

        if cache_model is not None:
            # http://lazka.github.io/pgi-docs/WebKit-3.0/functions.html#WebKit.set_cache_model
            set_cache_model(cache_model)

        # Setting for WebKit via git http://lazka.github.io/pgi-docs/#WebKit-3.0/classes/WebSettings.html
        settings = WebSettings()
        settings.set_property('enable-accelerated-compositing', True)
        settings.set_property('enable-file-access-from-file-uris', True)

        settings.set_property('enable-default-context-menu', not debug)

        webview = WebView()
        webview.set_settings(settings)
        return webview
コード例 #9
0
ファイル: replaygain.py プロジェクト: dreewoo/beets
    def _import_gst(self):
        """Import the necessary GObject-related modules and assign `Gst`
        and `GObject` fields on this object.
        """

        try:
            import gi
        except ImportError:
            raise FatalReplayGainError(
                "Failed to load GStreamer: python-gi not found"
            )

        try:
            gi.require_version('Gst', '1.0')
        except ValueError as e:
            raise FatalReplayGainError(
                "Failed to load GStreamer 1.0: {0}".format(e)
            )

        from gi.repository import GObject, Gst, GLib
        # Calling GObject.threads_init() is not needed for
        # PyGObject 3.10.2+
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            GObject.threads_init()
        Gst.init([sys.argv[0]])

        self.GObject = GObject
        self.GLib = GLib
        self.Gst = Gst
コード例 #10
0
ファイル: namespace.py プロジェクト: tobias47n9e/pgi-docgen
    def import_module(self):
        """Imports the module and initializes all dependencies.

        Can raise ImportError.
        """

        import gi

        # This is all needed because some modules depending on GStreamer
        # segfaults if Gst.init() isn't called before introspecting them
        to_load = list(reversed(self.get_all_dependencies()))
        to_load += [(self.namespace, self.version)]

        for (namespace, version) in to_load:
            try:
                gi.require_version(namespace, version)
            except ValueError as e:
                raise ImportError(e, version)

            module = util.import_namespace(namespace)

            # this needs to be synced with module._import_dependency
            if namespace in ("Clutter", "ClutterGst", "Gst", "Grl"):
                module.init([])
            elif namespace in ("Gsf", "IBus"):
                module.init()

        return module
コード例 #11
0
ファイル: wloc.py プロジェクト: xvitaly/wloc
def fetch_networks():
    # Importing Network Manager from GI repository and other modules...
    import gi, warnings
    gi.require_version('NetworkManager', '1.0')
    gi.require_version('NMClient', '1.0')
    from gi.repository import NetworkManager, NMClient

    # Creating new list for networks...
    netlist = []

    # Ignoring warnings on new Python versions...
    warnings.filterwarnings('ignore')

    # Connecting to Network Manager...
    nmclient = NMClient.Client.new()
    nmdevices = nmclient.get_devices()

    # Retrieving available networks...
    for nmdevice in nmdevices:
        if nmdevice.get_device_type() == NetworkManager.DeviceType.WIFI:
            for accesspoint in nmdevice.get_access_points():
                netlist.append([accesspoint.get_bssid(), conv_strength(accesspoint.get_strength())])

    # Returning result...
    return netlist
コード例 #12
0
def main():
    # These imports were moved here because the keysign module
    # can be imported without wanting to run it, e.g. setup.py
    # imports the __version__
    import logging, sys, signal
    
    import gi
    gi.require_version('Gtk', '3.0')
    from gi.repository import GLib, Gtk
    
    from .MainWindow import MainWindow

    logging.basicConfig(stream=sys.stderr,
        level=logging.DEBUG,
        format='%(name)s (%(levelname)s): %(message)s')

    app = MainWindow()

    try:
        GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT, lambda *args : app.quit(), None)
    except AttributeError:
        pass

    exit_status = app.run(None)

    return exit_status
コード例 #13
0
ファイル: util.py プロジェクト: davelab6/pgi-docgen
def import_namespace(namespace, version=None, ignore_version=False):
    """Equivalent to 'from gi.repository import <ns>'

    Returns the namespace module.
    Raises ImportError in case the import fails.
    """

    import gi

    if version is not None:
        try:
            gi.require_version(namespace, version)
        except ValueError as e:
            raise ImportError(e, version)

    with warnings.catch_warnings(record=True) as w:
        mod = getattr(
                __import__("gi.repository." + namespace).repository, namespace)

        if namespace in ("Clutter", "ClutterGst", "Gst", "Grl"):
            mod.init([])
        elif namespace in ("Gsf", "IBus"):
            mod.init()

        if not ignore_version:
            assert not w, namespace
        return mod
コード例 #14
0
ファイル: integration.py プロジェクト: ngld/knossos
def init():
    global current

    if sys.platform == 'win32':
        try:
            logging.info('Activating Windows integration...')
            current = WindowsIntegration()
            return
        except Exception:
            logging.exception('Failed to activate the Windows integration.')

    elif sys.platform.startswith('linux'):
        try:
            import gi
            try:
                if hasattr(gi, 'require_version'):
                    gi.require_version('Unity', '6.0')
            except Exception:
                logging.warning('Failed to specify Unity version. Most likely Unity is not available.')

            from gi.repository import Unity
        except ImportError:
            # Can't find Unity.
            pass
        else:
            logging.info('Activating Unity integration...')
            current = UnityIntegration(Unity)
            return

    logging.info('No desktop integration active.')
    current = Integration()
コード例 #15
0
ファイル: notify.py プロジェクト: flipcoder/siege-tools
def status(project, args):
    try:
        import gi
        gi.require_version('Notify','0.7')
        from gi.repository import Notify
        from gi.repository import GLib
    except:
        return
    
    global inited

    if not inited:
        Notify.init("sgmake")
        inited = True

    try:
        #if not "step" in args and not "start" in args:
        if "success" == args:
            Notify.Notification.new(
                "sgmake",
                "Build Complete",
                'dialog-information'
            ).show()
        
        if "failure" == args:
            Notify.Notification.new(
                "sgmake",
                "Build Failure",
                'dialog-error'
            ).show()
    except GLib.Error:
        pass # notifications disabled
コード例 #16
0
ファイル: paper.py プロジェクト: sdaps/sdaps
def _get_gtk_ppd_papersize(paper=None):
    try:
        import gi
        gi.require_version('Gtk', '3.0')
        from gi.repository import Gtk
    except:
        return paper, None
    else:
        def _find_papersize_by_ppd_name(paper=None):
            if not paper:
                return None

            paper = paper.lower()
            for papersize in Gtk.PaperSize.get_paper_sizes(False):
                if paper == papersize.get_ppd_name().lower():
                    return papersize

        papersize = _find_papersize_by_ppd_name(paper)
        if papersize is None:
            # Retrieve default paper size
            paper_name = Gtk.PaperSize.get_default()
            papersize = Gtk.PaperSize.new(paper_name)

        width = papersize.get_width(Gtk.Unit.MM)
        height = papersize.get_height(Gtk.Unit.MM)

        return papersize.get_ppd_name(), (width, height)
コード例 #17
0
ファイル: gstreamer_util.py プロジェクト: ljmljz/xpra
def import_gst1():
    log("import_gst1()")
    import gi
    log("import_gst1() gi=%s", gi)
    gi.require_version('Gst', '1.0')
    from gi.repository import Gst           #@UnresolvedImport
    log("import_gst1() Gst=%s", Gst)
    Gst.init(None)
    #make it look like pygst (gstreamer-0.10):
    Gst.registry_get_default = Gst.Registry.get
    Gst.get_pygst_version = lambda: gi.version_info
    Gst.get_gst_version = lambda: Gst.version()
    def new_buffer(data):
        buf = Gst.Buffer.new_allocate(None, len(data), None)
        buf.fill(0, data)
        return buf
    Gst.new_buffer = new_buffer
    Gst.element_state_get_name = Gst.Element.state_get_name
    #note: we only copy the constants we actually need..
    for x in ('NULL', 'PAUSED', 'PLAYING', 'READY', 'VOID_PENDING'):
        setattr(Gst, "STATE_%s" % x, getattr(Gst.State, x))
    for x in ('EOS', 'ERROR', 'TAG', 'STREAM_STATUS', 'STATE_CHANGED',
              'LATENCY', 'WARNING', 'ASYNC_DONE', 'NEW_CLOCK', 'STREAM_STATUS',
              'BUFFERING', 'INFO', 'STREAM_START'
              ):
        setattr(Gst, "MESSAGE_%s" % x, getattr(Gst.MessageType, x))
    Gst.MESSAGE_DURATION = Gst.MessageType.DURATION_CHANGED
    Gst.FLOW_OK = Gst.FlowReturn.OK
    global gst_version, pygst_version
    gst_version = Gst.get_gst_version()
    pygst_version = Gst.get_pygst_version()
    return Gst
コード例 #18
0
ファイル: _init.py プロジェクト: Muges/quodlibet
def _init_gst():
    """Call once before importing GStreamer"""

    assert "gi.repository.Gst" not in sys.modules

    import gi

    # We don't want python-gst, it changes API..
    assert "gi.overrides.Gst" not in sys.modules
    sys.modules["gi.overrides.Gst"] = None

    # blacklist some modules, simply loading can cause segfaults
    sys.modules["gst"] = None

    # We don't depend on Gst overrides, so make sure it's initialized.
    try:
        gi.require_version("Gst", "1.0")
        from gi.repository import Gst
    except (ValueError, ImportError):
        return

    if Gst.is_initialized():
        return

    from gi.repository import GLib

    try:
        ok, argv[:] = Gst.init_check(argv)
    except GLib.GError:
        print_e("Failed to initialize GStreamer")
        # Uninited Gst segfaults: make sure no one can use it
        sys.modules["gi.repository.Gst"] = None
    else:
        # monkey patching ahead
        _fix_gst_leaks()
コード例 #19
0
ファイル: pygtkcompat.py プロジェクト: GNOME/pygobject
def enable_vte():
    if _check_enabled("vte"):
        return

    gi.require_version('Vte', '0.0')
    from gi.repository import Vte
    _patch_module('vte', Vte)
コード例 #20
0
ファイル: test_prefs.py プロジェクト: Cangjians/ibus-cangjie
def has_graphical():
    """Detect if we have graphical capabilities

    It is very common to run the unit tests in an environment which does not
    have any graphical capabilities.

    This is for example the case in a CI server, or when building RPMs for
    Fedora.

    This function is useful to detect these situation, so that we can
    automatically skip the tests which can't run without.
    """
    try:
        import gi
        gi.require_version('Gtk', '3.0')
        from gi.repository import Gtk

    except RuntimeError as e:
        # On some platforms (e.g Ubuntu 12.04 where our CI is running) we
        # can't import Gtk without a display.
        return False

    # But other platforms (e.g Fedora 21) can import Gtk just fine even
    # without a display...

    gi.require_version('Gdk', '3.0')
    from gi.repository import Gdk

    if Gdk.Display.get_default() is None:
        # ... We don't have a display
        return False

    return True
コード例 #21
0
ファイル: rwlogger.py プロジェクト: RIFTIO/RIFT.ware
    def set_category(self, category_name):
        """
           Set Log category name to be used.
           Arguments:
              category_name (String): Yang module name that has log notifications. module_name will be used as category_name
           Returns: None
        """
        if category_name == self._category:
            return

        try:
            module_name = get_module_name_from_log_category(category_name)

            gi.require_version(module_name, '1.0')
            log_yang_module = importlib.import_module('gi.repository.' + module_name)

            if not log_yang_module:
                logger.error("Module %s is not found to be added as log category for %s", module_name, category_name)
                print("Module %s is not found to be added as log category for %s", module_name, category_name)
                return
            for level in RwLogger.level_event_cls_map.values():
                if not hasattr(log_yang_module, level):
                    logger.error("Module %s does not have required log notification for %s", module_name, level)
                    print("Module %s does not have required log notification for %s", module_name, level)
                    return
            self._log_yang_module = log_yang_module
            self._category = category_name

        except Exception as e:
            logger.exception("Caught error %s when trying to set log category (%s)",
                             repr(e), category_name)
コード例 #22
0
	def pre_test():
		try:
			import gi
			gi.require_version('Gtk', '3.0')
			from gi.repository import Gtk
		except:
			raise Exception("[!] Error: This program requires python Gtk+ 3.0 installed!")
コード例 #23
0
ファイル: JAMediaGstreamer.py プロジェクト: i5o/JAMediaSuite
    def __llenar_lista(self):

        try:
            import gi
            gi.require_version('Gst', '1.0')
            from gi.repository import Gst

            Gst.init([])

            registry = Gst.Registry.get()
            plugins = registry.get_plugin_list()

        except:
            return

        iter = self.lista.get_model().get_iter_first()

        for elemento in plugins:

            iteractual = self.lista.get_model().append(
                iter, [elemento.get_name(), elemento.get_description()])

            features = registry.get_feature_list_by_plugin(elemento.get_name())

            if len(features) > 1:
                for feature in features:
                    self.lista.get_model().append(
                        iteractual,
                        [feature.get_name(),
                        elemento.get_description()])
コード例 #24
0
ファイル: images.py プロジェクト: Cygn/pulseaudio-dlna
    def __init__(self, path, cached=True, size=256):
        try:
            gi.require_version('Rsvg', '2.0')
            from gi.repository import Rsvg
        except:
            raise MissingDependencies(
                'Unable to convert SVG image to PNG!', ['gir1.2-rsvg-2.0']
            )
        try:
            import cairo
        except:
            raise MissingDependencies(
                'Unable to convert SVG image to PNG!', ['cairo']
            )

        tmp_file = tempfile.NamedTemporaryFile()
        image_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, size, size)
        rsvg_handle = Rsvg.Handle.new_from_file(path)

        context = cairo.Context(image_surface)
        context.scale(
            float(size) / rsvg_handle.props.height,
            float(size) / rsvg_handle.props.width
        )
        rsvg_handle.render_cairo(context)
        image_surface.write_to_png(tmp_file.name)

        BaseImage.__init__(self, tmp_file.name, cached=True)
コード例 #25
0
ファイル: gstfunctions.py プロジェクト: hosle/tapas
def gst_init():
    from twisted.internet import gireactor as reactor
    reactor.install()
    import gi
    gi.require_version('Gst', '1.0')
    from gi.repository import GObject, Gst
    GObject.threads_init()
    Gst.init(None)
コード例 #26
0
ファイル: AppMixin.py プロジェクト: PhotoFilmStrip/PFS
    def InitGStreamer(self):
        import gi

        gi.require_version("Gst", "1.0")

        from gi.repository import Gst

        Gst.init(None)
コード例 #27
0
ファイル: gobject_compat.py プロジェクト: svn2github/Xpra
def import_gtk3():
    import gi

    gi.require_version("Gtk", "3.0")
    from gi.repository import Gtk  # @UnresolvedImport

    try_import_GdkX11()
    return Gtk
コード例 #28
0
ファイル: start.py プロジェクト: DMJackZ/XX-Net
 def has_gi():
     try:
         import gi
         gi.require_version('Gtk', '3.0')
         from gi.repository import Gtk as gtk
         return True
     except:
         return False
コード例 #29
0
ファイル: notify.py プロジェクト: flipcoder/siege-tools
def compatible(project):
    try:
        import gi
        gi.require_version('Notify','0.7')
        from gi.repository import Notify
    except ImportError:
        return Support.MASK & ~Support.ENVIRONMENT
    return Support.MASK
コード例 #30
0
ファイル: setup.py プロジェクト: freevo/kaa-candy
def check_version(name, version, major_version=0, minor_version=0):
    print 'checking for gir %s %s ...' % (name, version),
    try:
        gi.require_version(name, version)
    except ValueError, e:
        print 'not found'
        print e
        sys.exit(1)
コード例 #31
0
# Third Party Libraries
import gi

# Lutris Modules
from lutris.util.log import logger

NOTIFY_SUPPORT = True
try:
    gi.require_version('Notify', '0.7')
    from gi.repository import Notify
except ImportError:
    NOTIFY_SUPPORT = False

if NOTIFY_SUPPORT:
    Notify.init("lutris")
else:
    logger.warning("Notifications are disabled, please install"
                   " GObject bindings for 'Notify' to enable them.")


def send_notification(title, text, file_path_to_icon="lutris"):
    if NOTIFY_SUPPORT:
        notification = Notify.Notification.new(title, text, file_path_to_icon)
        notification.show()
    else:
        logger.info(title)
        logger.info(text)
コード例 #32
0
#!/usr/bin/python3

import re
import sys
import shlex
import base64
import os, sys
import requests
import argparse

import gi

gi.require_version('Secret', '1')
from gi.repository import Secret

from prompt_toolkit import prompt
from prompt_toolkit.history import InMemoryHistory

use_default = True
keyring_name = 'login'


def get_keyring(use_default, keyring_name):
    '''
    Returns a Secret.Collection object (keyring) and unlocks it if necessary. If {use_default}
    is set to True, the function will attempt to use the default keyring. If no default keyring
    is present, it creates a keyring {keyring_name} and sets it the default. If {use_default} is
    false, the function will attempt to open the keyring {keyring_name} and creates it if it not
    already exists.

    Parameters:
コード例 #33
0
# -*- coding: utf-8 -*-

from __future__ import print_function
import os
import sys
import re
import time
# pylint: disable=W0402
import string
import xml.etree.ElementTree as ET
import hashlib

from collections import namedtuple

import gi
gi.require_version('RwYang', '1.0')
gi.require_version('RwBaseYang', '1.0')
gi.require_version('RwDebugYang', '1.0')
gi.require_version('RwmsgDataYang', '1.0')
gi.require_version('RwMemlogYang', '1.0')


import gi.repository.GLib as glib
import gi.repository.RwYang as rwyang
import gi.repository.RwBaseYang as rwbase
import gi.repository.RwDebugYang as rwdebug
import gi.repository.RwmsgDataYang as rwmsg
import gi.repository.RwMemlogYang as rwmemlog


class RwMsgMessaging(object):
コード例 #34
0
 Gnome-TwoFactorAuth is free software: you can redistribute it and/or
 modify it under the terms of the GNU General Public License as published
 by the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 TwoFactorAuth is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with Gnome-TwoFactorAuth. If not, see <http://www.gnu.org/licenses/>.
"""
from gi import require_version
require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, GLib, Pango
from TwoFactorAuth.models.code import Code
from TwoFactorAuth.models.settings import SettingsReader
from TwoFactorAuth.models.database import Database
from TwoFactorAuth.widgets.confirmation import ConfirmationMessage
from TwoFactorAuth.utils import get_icon
from threading import Thread
from time import sleep
import logging
from gettext import gettext as _


class RowEntryName(Gtk.Entry):
    def __init__(self, name):
        self.name = name
コード例 #35
0
ファイル: RabbitVCS.py プロジェクト: xiegy1118/rabbitvcs
    sys.__excepthook__(type, value, tb)

# import sys
# sys.excepthook = log_all_exceptions

import copy

import os
import os.path
from os.path import isdir, isfile, realpath, basename
import datetime

from rabbitvcs.util import helper

import gi
gi.require_version('Nemo', '3.0')
sa = helper.SanitizeArgv()
from gi.repository import Nemo, GObject, Gtk, GdkPixbuf
sa.restore()

import pysvn

from rabbitvcs.vcs import VCS
import rabbitvcs.vcs.status

from rabbitvcs.util.helper import launch_ui_window, launch_diff_tool
from rabbitvcs.util.helper import get_file_extension, get_common_directory
from rabbitvcs.util.helper import get_home_folder
from rabbitvcs.util.helper import pretty_timedelta

from rabbitvcs.util.strings import S
コード例 #36
0
ファイル: webremote.py プロジェクト: GNOME/rhythmbox
# by the GPL license by which Rhythmbox is covered. If you modify this code
# you may extend this exception to your version of the code, but you are not
# obligated to do so. If you do not wish to do so, delete this exception
# statement from your version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.

import gi
gi.require_version('Soup', '2.4')
from gi.repository import GLib, GObject, Gio, Peas, PeasGtk, Soup, Gtk
from gi.repository import RB
import rb

import sys
import os.path
import json
import re
import time
import struct

import siphash

import gettext
gettext.install('rhythmbox', RB.locale_dir())
コード例 #37
0
# -*- coding: utf-8 -*-
import signal
import requests
import gi
import os
import time
gi.require_version('Gtk', '3.0')
gi.require_version('AppIndicator3', '0.1')
from gi.repository import Gtk as gtk
from gi.repository import AppIndicator3 as appindicator
from gi.repository import GObject
from threading import Thread


APPINDICATOR_ID = 'koinex_indicator'


class Indicator():
    def __init__(self):
        # Indicator logic
        iconpath = os.getcwd() + '/ethlogo.svg'
        self.indicator = appindicator.Indicator.new(APPINDICATOR_ID, iconpath, appindicator.IndicatorCategory.APPLICATION_STATUS)
        self.indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
        self.indicator.set_menu(self.build_menu())
        self.indicator.set_label('₹ 0 | $ 0', APPINDICATOR_ID)
        # Thread to update the price on the label
        self.update = Thread(target=self.get_current_price_koinex)
        # self.update.setDaemon(True)
        self.update.start()

    def build_menu(self):
コード例 #38
0
# SPDX-License-Identifier: LGPL-3.0-or-later
# Copyright (C) 2018 Takashi Sakamoto

import gi
gi.require_version('Hinawa', '2.0')
from gi.repository import Hinawa

from array import array
from math import log10

__all__ = [
    'EftInfo', 'EftFlash', 'EftTransmit', 'EftHwctl', 'EftPhysOutput',
    'EftPhysInput', 'EftPlayback', 'EftCapture', 'EftMonitor', 'EftIoconf'
]

#
# Category No.0, for hardware information
#


class EftInfo():
    SUPPORTED_MODELS = (
        'Audiofire2',
        'Audiofire4',
        'Audiofire8',
        'Audiofire8p',
        'Audiofire12',
        'Audiofire12HD',
        'Audiofire12Apple',
        'FireworksHDMI',
        'Onyx400F',
コード例 #39
0
#
# Author: Frank Sepulveda
# Email: [email protected]
#
# Display multiple CSI cameras as source in the screen
#
# gst-launch-1.0 nvarguscamerasrc bufapi-version=true sensor-id=0 ! "video/x-raw(memory:NVMM),width=1920,height=1080,framerate=30/1,format=NV12" ! m.sink_0 nvstreammux name=m batch-size=2 width=1280 height=720 live-source=1 ! nvinfer config-file-path=/opt/nvidia/deepstream/deepstream-5.0/samples/configs/deepstream-app/config_infer_primary.txt ! nvtracker tracker-width=640 tracker-height=480 ll-lib-file=/opt/nvidia/deepstream/deepstream-5.0/lib/libnvds_mot_klt.so enable-batch-process=1 ! nvvideoconvert ! "video/x-raw(memory:NVMM),format=RGBA" ! nvmultistreamtiler ! nvdsosd ! nvvideoconvert ! nvegltransform ! nveglglessink nvarguscamerasrc bufapi-version=true sensor-id=1 ! "video/x-raw(memory:NVMM),width=1920,height=1080,framerate=30/1,format=NV12" ! m.sink_1
#
import sys, gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst
from common.create_element_or_error import create_element_or_error


def main():

    cameras_list = [
        {
            "source": 0,
            "name": "Camera 1",
        },
        {
            "source": 1,
            "name": "Camera 2"
        },
    ]

    GObject.threads_init()
    Gst.init(None)

    pipeline = Gst.Pipeline()
コード例 #40
0
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
import gi
from gi.repository import Gtk, Gdk
gi.require_version('WebKit2', '4.0')
from gi.repository import WebKit2
from .gi_composites import GtkTemplate
from .settings_manager import *
from .adaptive_grid import *
from .overview import *
from .overview_toolbar import *
from .editor_toolbar import *
from .recent_db_manager import RecentDBManager
from .recent_note_list import RecentNoteList


@GtkTemplate(ui='/org/gnome/Carnetgtk/ui/res/window.ui')
class CarnetgtkWindow(Gtk.ApplicationWindow):
    __gtype_name__ = 'CarnetgtkWindow'
コード例 #41
0
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#
#
import os
import gi
try:
    gi.require_version('GLib', '2.0')
    gi.require_version('AppIndicator3', '0.1')
    gi.require_version('Gtk', '3.0')
    gi.require_version('GdkPixbuf', '2.0')
    gi.require_version('Notify', '0.7')
    gi.require_version('GeocodeGlib', '1.0')
    gi.require_version('WebKit', '3.0')
except:
    print('Repository version required not present')
    exit(1)
from gi.repository import GLib
from gi.repository import AppIndicator3 as appindicator
from gi.repository import Gtk
from gi.repository import GdkPixbuf
from gi.repository import Notify
from gi.repository import GObject
コード例 #42
0
import gi, threading, time, requests, RPi_I2C_driver, nfcReader
gi.require_version("Gtk", "3.0")
from gi.repository import GLib, Gtk, Gdk

user = {"uid": "", "name": ""}
table = {
    "rows": [],
    "name": "",
}


class Window(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self, title="MIRO CONNECTIVITY")
        self.set_default_size(500, 300)
        container = Gtk.Box(spacing=6)
        self.add(container)
        container.show()

        self.login = Login(self)
        self.query = Query(self)
        container.pack_start(self.login, True, True, 0)
        container.pack_start(self.query, True, True, 0)
        self.login.show_all()

        self.style_provider = Gtk.CssProvider()
        self.style_provider.load_from_path('estilitzat.css')
        Gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(), self.style_provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
コード例 #43
0
#!/usr/bin/python2

import gi
import math
import numpy as np
import matplotlib.pyplot as plt

gi.require_version('NumCosmo', '1.0')
gi.require_version('NumCosmoMath', '1.0')

from gi.repository import GObject
from gi.repository import NumCosmo as Nc
from gi.repository import NumCosmoMath as Ncm

from py_hiprim_example import PyHIPrimExample

#
# Script params
#
lmax = 2500

#
# Creating a new instance of PyHIPrimExample
#
prim = PyHIPrimExample ()

print "# As        = ", prim.props.As
print "# P (k = 1) = ", prim.SA_powspec_k (1.0)
print "# (a, b, c) = ( ", prim.props.a, ", ", prim.props.b, ", ", prim.props.c, " )"

#
コード例 #44
0
ファイル: replist.py プロジェクト: MarcusOettinger/borg-gtk
import common

import os
import json
import locale
import datetime
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gio

def simplest_path(path):
	home = os.path.expanduser('~')
	#if it's in the home directory, then
	if os.path.commonpath((path, home)) == home:
		return os.path.relpath(path, home)
	else:
		return path

def refresh():
	global listbox, config_file, config_data
	#clear the list
	listbox.foreach(lambda child, data: child.destroy(), None)
	del common.config_data

	common.config_file.seek(0)
	file_contents = common.config_file.read()
	if file_contents == '':
		common.config_data = {}
	else:
		common.config_data = json.loads(file_contents)
コード例 #45
0
import os
import pytest
import shlex
import requests
import shutil
import subprocess
import tempfile
import time
import uuid

import rift.auto.mano
import rift.auto.session
import rift.mano.examples.ping_pong_nsd as ping_pong

import gi
gi.require_version('RwMcYang', '1.0')
gi.require_version('RwNsrYang', '1.0')
gi.require_version('RwVnfdYang', '1.0')
gi.require_version('RwLaunchpadYang', '1.0')
gi.require_version('RwBaseYang', '1.0')

from gi.repository import (
    RwMcYang,
    NsdYang,
    RwNsrYang,
    RwVnfrYang,
    NsrYang,
    VnfrYang,
    VldYang,
    RwVnfdYang,
    RwLaunchpadYang,
コード例 #46
0
import os
import random
from random import randint
import numpy as np
import time
import gi
import io
from io import BytesIO
import logging

from PIL import Image, ImageDraw, ImageFont
import math
import requests

gi.require_version('Gst', '1.0')
gi.require_version('GstApp', '1.0')
gi.require_version('GstVideo', '1.0')

from gi.repository import GObject, Gst, GstVideo

from gst_lva_message import add_message, remove_message, get_message
from exception_handler import PrintGetExceptionDetails
import pyds
import inferencing_pb2
import media_pb2
import extension_pb2

GObject.threads_init()
Gst.init(None)