示例#1
0
    def __init__(self, *args, **kwargs):
        Connection.__init__(self, *args, **kwargs)

        self._client = Gio.SocketClient.new()
        self._client.set_timeout(7)

        if self._address.proxy is not None:
            self._proxy_resolver = self._address.proxy.get_resolver()
            self._client.set_proxy_resolver(self._proxy_resolver)

        GObject.Object.connect(self._client, 'event', self._on_event)

        self._con = None

        self._read_buffer = b''

        self._write_queue = deque([])
        self._write_stanza_buffer = None

        self._connect_cancellable = Gio.Cancellable()
        self._read_cancellable = Gio.Cancellable()

        self._tls_handshake_in_progress = False
        self._input_closed = False
        self._output_closed = False

        self._keepalive_id = None
示例#2
0
 def __init__(self, initial_search, view_type):
     """
         Init Popover
         @param initial_search as str
     """
     View.__init__(
         self, StorageType.COLLECTION | StorageType.SAVED
         | StorageType.SEARCH | StorageType.EPHEMERAL
         | StorageType.SPOTIFY_NEW_RELEASES | StorageType.SPOTIFY_SIMILARS,
         ViewType.SEARCH | ViewType.SCROLLED | ViewType.OVERLAY)
     Gtk.Bin.__init__(self)
     self.__timeout_id = None
     self.__current_search = ""
     self.__search = Search()
     self.__search.set_web_search(
         App().settings.get_value("web-search").get_string())
     self.__cancellable = Gio.Cancellable()
     self._empty_message = _("Search for artists, albums and tracks")
     self._empty_icon_name = "edit-find-symbolic"
     self.__cancellable = Gio.Cancellable()
     self.__banner = SearchBannerWidget()
     self.__banner.show()
     self.__stack = SearchStack(self.storage_type)
     self.__stack.show()
     self.add_widget(self.__stack, self.__banner)
     self.__banner.entry.connect("changed", self._on_search_changed)
     self.show_placeholder(True, _("Search for artists, albums and tracks"))
     self.set_search(initial_search)
     return [(self.__search, "match-artist", "_on_match_artist"),
             (self.__search, "match-album", "_on_match_album"),
             (self.__search, "match-track", "_on_match_track"),
             (self.__search, "finished", "_on_search_finished"),
             (App().settings, "changed::web-search",
              "_on_web_search_changed")]
示例#3
0
 def __init__(self):
     """
         Init player
     """
     self.__next_cancellable = Gio.Cancellable()
     self.__radio_cancellable = Gio.Cancellable()
     self.connect("next-changed", self.__on_next_changed)
示例#4
0
 def start(self):
     self.start_time = time.time()
     if not self.remote.query_exists(Gio.Cancellable()):
         logger.debug("Mounting remote volume")
         self.remote.mount_enclosing_volume(Gio.MountMountFlags.NONE,
                                            Gtk.MountOperation(),
                                            Gio.Cancellable(),
                                            self.mount_cb,
                                            None)
     else:
         logger.debug("Scheduling download")
         Gdk.threads_add_idle(GLib.PRIORITY_DEFAULT,
                              self.schedule_download, None)
    def __init__(self, command):

        Gtk.Window.__init__(
            self,
            title="Log Interface",
            default_width=500,
            default_height=400,
        )
        self.cancellable = Gio.Cancellable()

        self.start_button = Gtk.Button(label="Show log")
        self.start_button.connect("clicked", self.on_start_clicked)

        textview = Gtk.TextView()
        self.textbuffer = textview.get_buffer()
        scrolled = Gtk.ScrolledWindow()
        scrolled.add(textview)
        self.command = command
        progress = Gtk.ProgressBar(show_text=True)

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
                      spacing=6,
                      border_width=12)
        box.pack_start(self.start_button, False, True, 0)
        box.pack_start(progress, False, True, 0)
        box.pack_start(scrolled, True, True, 0)

        self.add(box)
示例#6
0
 def __init__(self, uri, page_id, window):
     """
         Init popover
         @param uri as str
         @param page_id as int
         @param window as Window
     """
     Gtk.Popover.__init__(self)
     self.set_modal(False)
     window.register(self)
     self.__cache_uris = []
     self.__uri = uri
     self.__page_id = page_id
     self.__cancellable = Gio.Cancellable()
     self.__filter = ""
     builder = Gtk.Builder()
     builder.add_from_resource("/org/gnome/Eolie/PopoverImages.ui")
     builder.connect_signals(self)
     widget = builder.get_object("widget")
     self.__spinner = builder.get_object("spinner")
     self.__flowbox = builder.get_object("flowbox")
     self.__flowbox.set_filter_func(self.__filter_func)
     self.__entry = builder.get_object("entry")
     self.__button = builder.get_object("button")
     self.add(widget)
     if Gio.NetworkMonitor.get_default().get_network_available():
         El().helper.call("GetImages", page_id, None, self.__on_get_images)
     (width, height) = El().active_window.get_size()
     self.set_size_request(width / 2, height / 1.5)
     self.connect("closed", self.__on_closed)
     self.__task_helper = TaskHelper()
示例#7
0
    def _load_profile_location(self, location, recursive, toplevel=False):
        try:
            info = location.query_info("standard::*",
                                       Gio.FileQueryInfoFlags.NONE, None)
        except GLib.Error as e:
            self._warning("Failed to load location %s: %s", location.get_uri(),
                          str(e.args))
            return

        if info.get_file_type() == Gio.FileType.DIRECTORY:
            if recursive or toplevel:
                monitor = location.monitor_directory(Gio.FileMonitorFlags.NONE,
                                                     Gio.Cancellable())
                self._debug("Adding %s as directory to watch",
                            location.get_uri())
                monitor.connect("changed", self._files_changed)
                self._monitors.append(monitor)
                self._debug("Descending into %s to find wallpapers",
                            location.get_uri())
                self._load_profile_children(location, recursive)
        elif info.get_file_type(
        ) == Gio.FileType.REGULAR and info.get_content_type(
        ) in self._accepted:
            self._debug("Adding wallpaper %s", location.get_uri())
            self._wallpapers.append(location.get_uri())
示例#8
0
    def on_scene_called(self):
        """
		Fired when the scene has been called.
		"""

        # Locked
        self.unlockbar.emit("locked")

        # Enter in the bus
        self.bus_cancellable = Gio.Cancellable()
        self.bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, self.bus_cancellable)
        self.VeraPowerManager = Gio.DBusProxy.new_sync(
            self.bus, 0, None, BUS_NAME,
            "/org/semplicelinux/vera/powermanager", BUS_NAME,
            self.bus_cancellable)
        # connect signals
        self.VeraPowerManager.connect(
            "g-signal",
            lambda proxy, sender, signal, params: self.signal_handlers[signal]
            (params) if signal in self.signal_handlers else None)

        # Check for backlight support
        if self.VeraPowerManager.IsBacklightSupported():
            self.objects.display_frame.show()
            self.on_brightness_level_changed_external()
        else:
            self.objects.display_frame.hide()

        # Update comboboxes
        self.building = True
        self.objects.power_button_action.set_active(
            ACTIONS.index(self.VeraPowerManager.GetHandlePowerKey()))
        self.objects.lid_switch_action.set_active(
            ACTIONS.index(self.VeraPowerManager.GetHandleLidSwitch()))
        self.building = False
示例#9
0
def get_icon(f):
    file = Gio.File.new_for_path("/")
    folder_info = file.query_info('standard::icon', 0, Gio.Cancellable())
    folder_icon = folder_info.get_icon().get_names()[0]
    icon_theme = Gtk.IconTheme.get_default()
    icon_folder = icon_theme.lookup_icon(folder_icon, 128, 0)
    if icon_folder:
        folder_icon = icon_folder.get_filename()
    else:
        folder_icon = "images/folder.png"

    if os.path.isdir(f):
        icon = folder_icon
    else:
        type_, encoding = mimetypes.guess_type(f)

        if type_:
            file_icon = Gio.content_type_get_icon(type_)
            file_info = icon_theme.choose_icon(file_icon.get_names(), 128, 0)
            if file_info:
                icon = file_info.get_filename()
            else:
                icon = "images/file.png"
        else:
            icon = "images/file.png"

    return icon
示例#10
0
 def _load_uri(self, uri, recursive, top_level=False):
     try:
         location = Gio.File.new_for_uri(uri)
         info = location.query_info('standard::*',
                                    Gio.FileQueryInfoFlags.NONE, None)
     except GLib.Error as e:
         logger.warning('failed to load location %s: %s', uri, str(e.args))
         return
     if info.get_file_type() == Gio.FileType.DIRECTORY and (recursive
                                                            or top_level):
         monitor = location.monitor_directory(Gio.FileMonitorFlags.NONE,
                                              Gio.Cancellable())
         logger.debug('adding %s as directory to watch', location.get_uri())
         monitor.connect('changed', self._files_changed)
         self._monitors.append(monitor)
         logger.debug('descending into %s to find wallpapers',
                      location.get_uri())
         self._load_children(location, recursive)
     elif info.get_file_type(
     ) == Gio.FileType.REGULAR and info.get_content_type() in ACCEPTED:
         logger.debug('adding wallpaper %s', location.get_uri())
         if location.get_uri() in self._wallpapers:
             logger.warning('%s already loaded, skipping duplicate',
                            location.get_uri())
             return
         self._wallpapers.append(location.get_uri())
示例#11
0
 def __init__(self):
     """
         Init playbin
     """
     # In the case of gapless playback, both 'about-to-finish'
     # and 'eos' can occur during the same stream.
     self.__track_in_pipe = False
     self.__cancellable = Gio.Cancellable()
     self.__codecs = Codecs()
     self._current_track = Track()
     self._next_track = Track()
     self._prev_track = Track()
     self._playbin = self._playbin1 = Gst.ElementFactory.make(
         "playbin", "player")
     self._playbin2 = Gst.ElementFactory.make("playbin", "player")
     self._plugins = self._plugins1 = PluginsPlayer(self._playbin1)
     self._plugins2 = PluginsPlayer(self._playbin2)
     for playbin in [self._playbin1, self._playbin2]:
         flags = playbin.get_property("flags")
         flags &= ~GstPlayFlags.GST_PLAY_FLAG_VIDEO
         playbin.set_property("flags", flags)
         playbin.set_property("buffer-size", 5 << 20)
         playbin.set_property("buffer-duration", 10 * Gst.SECOND)
         playbin.connect("notify::volume", self.__on_volume_changed)
         playbin.connect("about-to-finish", self._on_stream_about_to_finish)
         bus = playbin.get_bus()
         bus.add_signal_watch()
         bus.connect("message::error", self._on_bus_error)
         bus.connect("message::eos", self._on_bus_eos)
         bus.connect("message::element", self._on_bus_element)
         bus.connect("message::stream-start", self._on_stream_start)
         bus.connect("message::tag", self._on_bus_message_tag)
     self._start_time = 0
示例#12
0
文件: async.py 项目: bjtj/tjsamples
    def __init__(self):
        super(DownloadWindow, self).__init__(default_width=500,
                                             default_height=400,
                                             title="Async I/O Example")

        self.cancellable = Gio.Cancellable()

        self.cancel_button = Gtk.Button(label="Cancel")
        self.cancel_button.connect("clicked", self.on_cancel_clicked)
        self.cancel_button.set_sensitive(False)

        self.start_button = Gtk.Button(label="Load")
        self.start_button.connect("clicked", self.on_start_clicked)

        textview = Gtk.TextView()
        self.textbuffer = textview.get_buffer()
        scrolled = Gtk.ScrolledWindow()
        scrolled.add(textview)

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
                      spacing=6,
                      border_width=12)
        box.pack_start(self.start_button, False, True, 0)
        box.pack_start(self.cancel_button, False, True, 0)
        box.pack_start(scrolled, True, True, 0)

        self.add(box)
示例#13
0
 def __init__(self, artist_id):
     """
         Init popover
         @param artist_id as int
     """
     Gtk.Bin.__init__(self)
     (path, env) = get_youtube_dl()
     self.__show_all = path is not None
     self.__added = []
     self.__artist_id = artist_id
     self.__cancellable = Gio.Cancellable()
     self.connect("map", self.__on_map)
     self.connect("unmap", self.__on_unmap)
     self.__stack = Gtk.Stack.new()
     self.__stack.show()
     self.__stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
     self.__stack.set_transition_duration(200)
     self.__label = Gtk.Label.new(_("Loading…"))
     self.__label.get_style_context().add_class("bold")
     self.__label.get_style_context().add_class("dim-label")
     self.__label.show()
     self.__listbox = Gtk.ListBox()
     self.__listbox.get_style_context().add_class("trackswidget")
     self.__listbox.set_vexpand(True)
     self.__listbox.set_selection_mode(Gtk.SelectionMode.NONE)
     self.__listbox.set_activate_on_single_click(True)
     self.__listbox.connect("row-activated", self.__on_row_activated)
     self.__listbox.set_sort_func(self.__sort_func)
     self.__listbox.show()
     self.__stack.add(self.__label)
     self.__stack.add(self.__listbox)
     self.add(self.__stack)
     self.set_hexpand(True)
 def __init__(self):
     """
         Init popover
     """
     Popover.__init__(self)
     self.__lastfm_signal_id = None
     self.__spotify_signal_id = None
     builder = Gtk.Builder()
     builder.add_from_resource("/org/gnome/Lollypop/SimilarsPopover.ui")
     self.__show_all = GLib.find_program_in_path("youtube-dl") is not None
     self.__added = []
     self.__cancellable = Gio.Cancellable()
     self.connect("map", self.__on_map)
     self.connect("unmap", self.__on_unmap)
     self.__stack = builder.get_object("stack")
     self.__spinner = builder.get_object("spinner")
     self.__spinner.start()
     self.__listbox = Gtk.ListBox()
     self.__listbox.get_style_context().add_class("trackswidget")
     self.__listbox.set_vexpand(True)
     self.__listbox.set_selection_mode(Gtk.SelectionMode.NONE)
     self.__listbox.set_activate_on_single_click(True)
     self.__listbox.connect("row-activated", self.__on_row_activated)
     self.__listbox.show()
     self.__stack.add(self.__listbox)
     self.add(builder.get_object("widget"))
示例#15
0
 def __populate(self):
     """
         Populate searching items
         in db based on text entry current text
     """
     self.__cancellable = Gio.Cancellable()
     self.__button_stack.set_visible_child(self.__spinner)
     self.__history = []
     if len(self.__current_search) > 2:
         self.__spinner.start()
         state = self.__search_type_action.get_state().get_string()
         current_search = self.__current_search.lower()
         if state == "local":
             search = Search()
             search.get(current_search,
                        self.__cancellable,
                        callback=(self.__on_search_get, current_search))
         elif state == "web":
             App().task_helper.run(App().spotify.search, current_search,
                                   self.__cancellable)
     else:
         self.__stack.set_visible_child_name("placeholder")
         self.__set_default_placeholder()
         self.__button_stack.set_visible_child(self.__new_button)
         GLib.idle_add(self.__spinner.stop)
示例#16
0
 def __init__(self, uri, page_id):
     """
         Init popover
         @param uri as str
         @param page_id as int
     """
     Gtk.Popover.__init__(self)
     self.__uri = uri
     self.__page_id = page_id
     self.__cancellable = Gio.Cancellable()
     self.__filter = ""
     builder = Gtk.Builder()
     builder.add_from_resource("/org/gnome/Eolie/PopoverImages.ui")
     builder.connect_signals(self)
     widget = builder.get_object("widget")
     self.__spinner = builder.get_object("spinner")
     self.__flowbox = builder.get_object("flowbox")
     self.__flowbox.set_filter_func(self.__filter_func)
     self.__entry = builder.get_object("entry")
     self.__button = builder.get_object("button")
     self.add(widget)
     if Gio.NetworkMonitor.get_default().get_network_available():
         helper = DBusHelper()
         helper.call("GetImages",
                     GLib.Variant("(i)", (page_id,)),
                     self.__on_get_images, None)
     (width, height) = El().active_window.get_size()
     self.set_size_request(width / 2, height / 1.5)
     self.connect("closed", self.__on_closed)
示例#17
0
	def on_scene_called(self):
		"""
		Fired when the scene has been called.
		"""

		# Create the OsRelease object
		self.osrelease = OsRelease()

		# Enter in the bus
		self.bus_cancellable = Gio.Cancellable()
		self.bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, self.bus_cancellable)
		self.Hostname = Gio.DBusProxy.new_sync(
			self.bus,
			0,
			None,
			BUS_NAME,
			"/org/freedesktop/hostname1",
			BUS_NAME,
			self.bus_cancellable
		)
		self.HostnameProperties = Gio.DBusProxy.new_sync(
			self.bus,
			0,
			None,
			BUS_NAME,
			"/org/freedesktop/hostname1",
			"org.freedesktop.DBus.Properties",
			self.bus_cancellable
		) # Really we should create a new proxy to get the properties?!
		
		#self.refresh_infos()
				
		self.update()
示例#18
0
    def __on_method_call(
        self,
        connection,
        sender,
        object_path,
        interface_name,
        method_name,
        parameters,
        invocation,
    ):
        method_fname = self.__fname(interface_name, method_name)
        method_info = self.__methods[method_fname]

        args = list(parameters.unpack())

        context = DBusMethodCallContext(connection, sender, object_path,
                                        method_info)
        job = DBusMethodCallJob(self.application, method_info, args,
                                invocation, context)
        cancellable = Gio.Cancellable()

        old_job = self.__method_calls.pop(method_name, None)
        if old_job:
            old_job.cancel()
        self.__method_calls[method_name] = cancellable

        Gio.io_scheduler_push_job(job.run_async, None, GLib.PRIORITY_DEFAULT,
                                  cancellable)
示例#19
0
 def __on_unmap(self, widget):
     """
         Cancel drawing
         @param widget as Gtk.Widget
     """
     self.__cancellable.cancel()
     self.__cancellable = Gio.Cancellable()
示例#20
0
    def __init__(self):
        """
            Init Popover
        """
        BaseView.__init__(self)
        Gtk.Bin.__init__(self)
        self.connect("map", self.__on_map)
        self.connect("unmap", self.__on_unmap)
        self.__timeout_id = None
        self.__current_search = ""
        self.__cancellable = Gio.Cancellable()
        self.__history = []

        builder = Gtk.Builder()
        builder.add_from_resource("/org/gnome/Lollypop/SearchView.ui")
        builder.connect_signals(self)
        self.__widget = builder.get_object("widget")
        self.__new_button = builder.get_object("new_button")
        self.__play_button = builder.get_object("play_button")
        self.__entry = builder.get_object("entry")
        self.__spinner = builder.get_object("spinner")
        self.__header_stack = builder.get_object("header_stack")
        self.__stack = builder.get_object("stack")
        self.__placeholder = builder.get_object("placeholder")
        self.__view = AlbumsListView(RowListType.SEARCH)
        self.__view.show()
        self.__stack.add_named(self.__view, "view")
        self.__set_default_placeholder()
        self.add(self.__widget)
 def __init__(self):
     """
         Init view
     """
     View.__init__(self)
     InformationController.__init__(
         self, False,
         ArtBehaviour.BLUR_MAX | ArtBehaviour.CROP | ArtBehaviour.DARKER)
     self.__current_changed_id = None
     self.__size_allocate_timeout_id = None
     self.__lyrics_timeout_id = None
     self.__downloads_running = 0
     self.__lyrics_text = ""
     self.__size = 0
     self.__cancellable = Gio.Cancellable()
     builder = Gtk.Builder()
     builder.add_from_resource("/org/gnome/Lollypop/LyricsView.ui")
     builder.connect_signals(self)
     self._artwork = builder.get_object("cover")
     self.__lyrics_label = LyricsLabel()
     self.__lyrics_label.show()
     builder.get_object("viewport").add(self.__lyrics_label)
     self.__translate_button = builder.get_object("translate_button")
     # We do not use View scrolled window because it does not work with
     # an overlay
     self.add(builder.get_object("widget"))
     self.connect("size-allocate", self.__on_size_allocate)
     self.__sync_lyrics_helper = SyncLyricsHelper()
 def __init__(self, album, height, view_type, reveal, cover_uri, parent):
     """
         Init row widgets
         @param album as Album
         @param height as int
         @param view_type as ViewType
         @param reveal as bool
         @param parent as AlbumListView
     """
     Gtk.ListBoxRow.__init__(self)
     TracksView.__init__(self, view_type)
     if view_type & ViewType.DND:
         DNDRow.__init__(self)
     self.__next_row = None
     self.__previous_row = None
     self.__revealer = None
     self.__parent = parent
     self.__reveal = reveal
     self.__cover_uri = cover_uri
     self._artwork = None
     self._album = album
     self.__view_type = view_type
     self.__cancellable = Gio.Cancellable()
     self.set_sensitive(False)
     self.set_property("height-request", height)
     self.connect("destroy", self.__on_destroy)
示例#23
0
    def icon(self, icon_size=16, save=True):
        """
        Get file type icon for File
        :param icon_size: requested icon size
        :param save: True to copy icon to media flder, otherwise will return path where OS stores the icon
        :return: full absolute path to File icon or nothing
        """
        if platform.system() == 'Linux':
            try:
                file = Gio.File.new_for_path(self.path)

                file_info = file.query_info('standard::icon', 0, Gio.Cancellable())
                file_icon = file_info.get_icon().get_names()[0]

                icon_theme = Gtk.IconTheme.get_default()
                icon_info = icon_theme.lookup_icon(file_icon, icon_size, 0)
                icon_path = icon_info.get_filename()
            except (NameError, AttributeError):
                return ''

            if os.path.isfile(icon_path):
                if save:
                    icon_store_path = os.path.join(self.folder_dir_path, 'media', 'fileicons')
                    if not os.path.isfile(icon_store_path + os.sep + os.path.basename(icon_path)):
                        try:
                            os.makedirs(icon_store_path, exist_ok=True)
                            icon_path = shutil.copy(icon_path, icon_store_path)
                            icon_path = 'media/fileicons/' + os.path.basename(icon_path)
                        except OSError:
                            pass

                return icon_path
示例#24
0
 def __play_radio_common(self):
     """
         Emit signal and reset cancellable
     """
     emit_signal(self, "loading-changed", True, Track())
     self.__radio_cancellable.cancel()
     self.__radio_cancellable = Gio.Cancellable()
示例#25
0
 def gio_copy_in_place(self, file):
     "helper that copies the file to the local system via gio"
     gio_file = Gio.file_new_for_path(file)
     if (gio_file.get_uri_scheme() == "file"):
         return file
     if (os.getuid()==0):
         self.show_alert(Gtk.MessageType.ERROR,
                         _("Can not download as root"),
                         _("Remote packages can not be downloaded when "
                           "running as root. Please try again as a "
                           "normal user."))
         sys.exit(1)
     # Download the file
     temp_file_name = os.path.join(tempfile.mkdtemp(),os.path.basename(file))
     gio_dest = Gio.file_new_for_path(temp_file_name)
     try:
         # download
         gio_cancellable = Gio.Cancellable()
         self.button_cancel_download.connect("clicked", self.on_button_cancel_download_clicked, gio_cancellable)
         self.dialog_gio_download.set_transient_for(self.window_main)
         self.dialog_gio_download.show()
         self.label_action.set_text(_("Downloading package"))
         if gio_file.copy(gio_dest, 0, gio_cancellable,
                          self.gio_progress_callback, 0):
             file = gio_dest.get_path()
         self.dialog_gio_download.hide()
     except Exception as e:
         self.show_alert(Gtk.MessageType.ERROR,
                         _("Download failed"),
                         _("Downloading the package failed: "
                           "file '%s' '%s'") % (file, e))
         sys.exit(1)
     return file
    def __on_method_call(
        self,
        connection,
        sender,
        object_path,
        interface_name,
        method_name,
        parameters,
        invocation,
    ):
        method_fname = self.__fname(interface_name, method_name)
        method_info = self.__methods[method_fname]

        args = list(parameters.unpack())

        context = DBusMethodCallContext(connection, sender, object_path, method_info)
        job = DBusMethodCallJob(
            self.application, method_info, args, invocation, context
        )
        cancellable = Gio.Cancellable()

        old_job = self.__method_calls.pop(method_name, None)
        if old_job:
            old_job.cancel()
        self.__method_calls[method_name] = cancellable

        # TODO: Instead, call job.run_async in a thread

        job.run(cancellable)
示例#27
0
 def __populate_db(self):
     """
         Populate DB in a background task
     """
     try:
         Logger.info("Collection download started")
         self.__is_running = True
         self.__cancellable = Gio.Cancellable()
         storage_types = []
         mask = App().settings.get_value("suggestions-mask").get_int32()
         # Check if storage type needs to be updated
         # Check if albums newer than a week are enough
         timestamp = time() - 604800
         for storage_type in self.__STORAGE_TYPES:
             if not mask & storage_type:
                 continue
             newer_albums = App().albums.get_newer_for_storage_type(
                 storage_type, timestamp)
             if len(newer_albums) < self.MIN_ITEMS_PER_STORAGE_TYPE:
                 storage_types.append(storage_type)
         # Update needed storage types
         if storage_types:
             for storage_type in storage_types:
                 if self.__cancellable.is_cancelled():
                     raise Exception("cancelled")
                 self.__METHODS[storage_type](self, self.__cancellable)
             self.clean_old_albums(storage_types)
             App().artists.update_featuring()
     except Exception as e:
         Logger.warning("CollectionWebService::__populate_db(): %s", e)
     self.__is_running = False
     Logger.info("Collection download finished")
示例#28
0
    def start_verify(self, p, identify=False):
        self._verify_match = None
        self._verify_fp = None
        self._verify_error = None
        self._verify_report_match = None
        self._verify_report_print = None
        self._verify_completed = False
        self._verify_reported = False
        self._cancellable = Gio.Cancellable()

        if identify:
            self.assertTrue(self.dev.supports_identify())

        def match_cb(dev, match, pnt, data, error):
            self._verify_reported = True
            self._verify_report_match = match
            self._verify_report_print = pnt
            self._verify_report_error = error

        def verify_cb(dev, res):
            try:
                self._verify_match, self._verify_fp = (
                    dev.identify_finish(res) if identify else dev.verify_finish(res))
            except gi.repository.GLib.Error as e:
                self._verify_error = e

            self._verify_completed = True

        if identify:
            self.dev.identify(p if isinstance(p, list) else [p],
                cancellable=self._cancellable, match_cb=match_cb, callback=verify_cb)
        else:
            self.dev.verify(p, cancellable=self._cancellable, match_cb=match_cb,
                callback=verify_cb)
示例#29
0
    def on_scene_called(self):
        """
		Fired when the scene has been called.
		"""

        # Load current variant
        if os.path.exists(VARIANT_FILE):
            with open(VARIANT_FILE, "r") as f:
                self.current_variant = f.read().strip()

        # Enter in the bus
        self.bus_cancellable = Gio.Cancellable()
        self.bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, self.bus_cancellable)
        self.Channels = Gio.DBusProxy.new_sync(
            self.bus, 0, None, BUS_NAME,
            "/org/semplicelinux/channels/channels",
            "org.semplicelinux.channels.channels", self.bus_cancellable)
        self.Providers = Gio.DBusProxy.new_sync(
            self.bus, 0, None, BUS_NAME,
            "/org/semplicelinux/channels/providers",
            "org.semplicelinux.channels.providers", self.bus_cancellable)

        # We are locked
        self.unlockbar.emit("locked")

        self.load()
 def __init__(self):
     """
         Init playbin
     """
     BasePlayer.__init__(self)
     self.__cancellable = Gio.Cancellable()
     self.__codecs = Codecs()
     self._playbin = self.__playbin1 = Gst.ElementFactory.make(
         "playbin", "player")
     self.__playbin2 = Gst.ElementFactory.make("playbin", "player")
     self._plugins = self._plugins1 = PluginsPlayer(self.__playbin1)
     self._plugins2 = PluginsPlayer(self.__playbin2)
     self._playbin.connect("notify::volume", self.__on_volume_changed)
     for playbin in [self.__playbin1, self.__playbin2]:
         flags = playbin.get_property("flags")
         flags &= ~GstPlayFlags.GST_PLAY_FLAG_VIDEO
         playbin.set_property("flags", flags)
         playbin.set_property("buffer-size", 5 << 20)
         playbin.set_property("buffer-duration", 10 * Gst.SECOND)
         playbin.connect("about-to-finish",
                         self._on_stream_about_to_finish)
         bus = playbin.get_bus()
         bus.add_signal_watch()
         bus.connect("message::error", self._on_bus_error)
         bus.connect("message::eos", self._on_bus_eos)
         bus.connect("message::element", self._on_bus_element)
         bus.connect("message::stream-start", self._on_stream_start)
         bus.connect("message::tag", self._on_bus_message_tag)
     self._start_time = 0