def __stop_response_cb(self, alert, response_id):
     if response_id == Gtk.ResponseType.APPLY:
         logging.debug('Start application with downloaded object')
         launch_bundle(object_id=self._object_id)
     if response_id == Gtk.ResponseType.ACCEPT:
         activity.show_object_in_journal(self._object_id)
     self._activity.remove_alert(alert)
예제 #2
0
파일: activity.py 프로젝트: dnarvaez/Pippy
 def journal_show_object(self, object_id):
     """Invoke journal_show_object from sugar.activity.activity if it
     exists."""
     try:
         from sugar3.activity.activity import show_object_in_journal
         show_object_in_journal(object_id)
     except ImportError:
         pass  # no love from sugar.
예제 #3
0
    def _on_send_button_clicked_cb(self, button):
        window = self._activity.get_window()
        old_cursor = window.get_cursor()
        window.set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH))
        Gdk.flush()

        identifier = str(int(time.time()))
        filename = '%s.zip' % identifier
        filepath = os.path.join(activity.get_activity_root(), filename)
        success = True
        # FIXME: subprocess or thread
        try:
            self._collector.write_logs(archive=filepath, logbytes=0)
        except:
            success = False

        self.popdown(True)

        if not success:
            title = _('Logs not captured')
            msg = _('The logs could not be captured.')

            notify = NotifyAlert()
            notify.props.title = title
            notify.props.msg = msg
            notify.connect('response', _notify_response_cb, self._activity)
            self._activity.add_alert(notify)

        jobject = datastore.create()
        metadata = {
            'title': _('log-%s') % filename,
            'title_set_by_user': '******',
            'suggested_filename': filename,
            'mime_type': 'application/zip',
        }
        for k, v in metadata.items():
            jobject.metadata[k] = v
        jobject.file_path = filepath
        datastore.write(jobject)
        self._last_log = jobject.object_id
        jobject.destroy()
        activity.show_object_in_journal(self._last_log)
        os.remove(filepath)

        window.set_cursor(old_cursor)
        Gdk.flush()
예제 #4
0
 def __open_on_journal(self, widget, url):
     '''Ask the journal to display a URL'''
     jobject = datastore.create()
     metadata = {
         'title': '%s: %s' % (_('URL from Speak'), url),
         'title_set_by_user': '******',
         'icon-color': profile.get_color().to_string(),
         'mime_type': 'text/uri-list',
     }
     for k, v in list(metadata.items()):
         jobject.metadata[k] = v
     file_path = os.path.join(get_activity_root(), 'instance',
                              '%i_' % time.time())
     open(file_path, 'w').write(url + '\r\n')
     os.chmod(file_path, 0o755)
     jobject.set_file_path(file_path)
     datastore.write(jobject)
     show_object_in_journal(jobject.object_id)
     jobject.destroy()
     os.unlink(file_path)
예제 #5
0
파일: chat.py 프로젝트: sugarlabs/speak
 def __open_on_journal(self, widget, url):
     '''Ask the journal to display a URL'''
     jobject = datastore.create()
     metadata = {
         'title': '%s: %s' % (_('URL from Speak'), url),
         'title_set_by_user': '******',
         'icon-color': profile.get_color().to_string(),
         'mime_type': 'text/uri-list',
     }
     for k, v in metadata.items():
         jobject.metadata[k] = v
     file_path = os.path.join(get_activity_root(), 'instance',
                              '%i_' % time.time())
     open(file_path, 'w').write(url + '\r\n')
     os.chmod(file_path, 0755)
     jobject.set_file_path(file_path)
     datastore.write(jobject)
     show_object_in_journal(jobject.object_id)
     jobject.destroy()
     os.unlink(file_path)
예제 #6
0
    def __handle_link_cb(self, widget, url_object):
        url = url_object.get_uri()
        logging.debug('Create journal entry for URL: %s', url)
        jobject = datastore.create()
        metadata = {
            'title': "%s: %s" % (_('URL from Read'), url),
            'title_set_by_user': '******',
            'icon-color': profile.get_color().to_string(),
            'mime_type': 'text/uri-list', }

        for k, v in metadata.items():
            jobject.metadata[k] = v
        file_path = os.path.join(get_activity_root(),
                                 'instance', '%i_' % time.time())
        open(file_path, 'w').write(url + '\r\n')
        os.chmod(file_path, 0755)
        jobject.set_file_path(file_path)
        datastore.write(jobject)
        show_object_in_journal(jobject.object_id)
        jobject.destroy()
        os.unlink(file_path)
예제 #7
0
    def _on_send_button_clicked_cb(self, button):
        identifier = str(int(time.time()))
        filename = '%s.zip' % identifier
        filepath = os.path.join(activity.get_activity_root(), filename)
        success = True
        try:
            self._collector.write_logs(archive=filepath, logbytes=0)
        except:
            success = False

        self.popdown(True)

        if not success:
            title = _('Logs not captured')
            msg = _('The logs could not be captured.')

            notify = NotifyAlert()
            notify.props.title = title
            notify.props.msg = msg
            notify.connect('response', _notify_response_cb, self._activity)
            self._activity.add_alert(notify)

        jobject = datastore.create()
        metadata = {
            'title': _('log-%s') % filename,
            'title_set_by_user': '******',
            'suggested_filename': filename,
            'mime_type': 'application/zip',
        }
        for k, v in metadata.items():
            jobject.metadata[k] = v
        jobject.file_path = filepath
        datastore.write(jobject)
        self._last_log = jobject.object_id
        jobject.destroy()
        activity.show_object_in_journal(self._last_log)
        os.remove(filepath)
예제 #8
0
 def __stop_response_cb(self, alert, response_id):
     if response_id == Gtk.ResponseType.APPLY:
         launch_bundle(object_id=self._object_id)
     if response_id == Gtk.ResponseType.ACCEPT:
         activity.show_object_in_journal(self._object_id)
     self._activity.remove_alert(alert)
예제 #9
0
 def __stop_response_cb(self, alert, response_id):
     if response_id is Gtk.ResponseType.APPLY:
         activity.show_object_in_journal(self._object_id)
     self.remove_alert(alert)
 def __stop_response_cb(self, alert, response_id):
     global _active_downloads
     if response_id is Gtk.ResponseType.APPLY:
         logging.debug('Start application with downloaded object')
         activity.show_object_in_journal(self._object_id)
     self._activity.remove_alert(alert)
예제 #11
0
 def __stop_response_cb(self, alert, response_id):
     if response_id is Gtk.ResponseType.APPLY:
         activity.show_object_in_journal(self._object_id)
     self.remove_alert(alert)
예제 #12
0
 def __book_saved_alert_response_cb(self, alert, response_id,
                                    book_object_id):
     if response_id is Gtk.ResponseType.APPLY:
         activity.show_object_in_journal(book_object_id)
     self.remove_alert(alert)
 def __stop_response_cb(self, alert, response_id):
     if response_id is Gtk.ResponseType.APPLY:
         activity.show_object_in_journal(self._object_id)
     elif response_id is Gtk.ResponseType.ACCEPT:
         launch_bundle(object_id=self._object_id)
     self.remove_alert(alert)
예제 #14
0
 def __stop_response_cb(self, alert, response_id):
     global _active_downloads
     if response_id is Gtk.ResponseType.APPLY:
         logging.debug('Start application with downloaded object')
         activity.show_object_in_journal(self._object_id)
     self._activity.remove_alert(alert)
예제 #15
0
 def __alert_response_cb(self, alert, response_id, object_id):
     if response_id is Gtk.ResponseType.ACCEPT:
         launch_bundle(object_id=object_id)
     if response_id is Gtk.ResponseType.APPLY:
         activity.show_object_in_journal(object_id)
     self.remove_alert(alert)
예제 #16
0
 def __book_saved_alert_response_cb(self, alert, response_id,
                                    book_object_id):
     if response_id is Gtk.ResponseType.APPLY:
         activity.show_object_in_journal(book_object_id)
     self.remove_alert(alert)
예제 #17
0
    def __pdf_response_alert(self, alert, response_id, object_id):

        if response_id is Gtk.ResponseType.APPLY:
            activity.show_object_in_journal(object_id)

        self._activity.remove_alert(alert)
예제 #18
0
    def __pdf_response_alert(self, alert, response_id, object_id):

        if response_id is Gtk.ResponseType.APPLY:
            activity.show_object_in_journal(object_id)

        self._activity.remove_alert(alert)