This file is indexed.

/usr/share/pyshared/AptUrl/kde/KdeUI.py is in apturl-kde 0.5.1ubuntu3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# -*- coding: utf-8 -*-

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import QWebView
from PyQt4 import uic
from PyKDE4.kdeui import *
from PyKDE4.kdecore import *

import subprocess
from tempfile import NamedTemporaryFile

import os
import os.path

import time
import thread
import apt_pkg

from AptUrl.UI import AbstractUI
from AptUrl import Helpers
from AptUrl.Helpers import utf8, _, _n

class AptUrlDialog(KDialog):
    def __init__(self,parent=None):
        KDialog.__init__(self,parent)
        self.setWindowIcon(KIcon("application-x-deb"))

    def slotButtonClicked(self,button):
        if button in (KDialog.Apply, KDialog.Ok, KDialog.Yes):
            KDialog.accept(self)
        else:
            KDialog.reject(self)

class KdeUI(AbstractUI):
    def __init__(self):
        self.dialog = AptUrlDialog()

        self.d = QWidget(self.dialog)
        self.dialog.setMainWidget(self.d)

        uic.loadUi('/usr/share/apturl/apturl-qt.ui', self.d)
        self.d.image_label.setPixmap(KIcon("application-x-deb").pixmap(64,64))

    # generic dialogs
    def _get_dialog(self, dialog_type, summary, msg="", buttons=KDialog.Close):
        self.dialog.setButtons(KDialog.ButtonCode(buttons))
        self.d.header_label.setText("<h2>" + summary + "</h2>")
        self.d.body_label.setText(msg)
        # TODO: title = empty
        # TODO: keep above maintain across events
        # TODO: d.set_markup("<big><b>%s</b></big>\n\n%s" % (summary, msg))

    def error(self, summary, msg=""):
        if msg != "":
            KMessageBox.detailedError(AptUrlDialog(), summary, msg)
        else:
            KMessageBox.error(AptUrlDialog(), summary)
        return False

    def message(self, summary, msg="", title=""):
        if msg != "":
            summary += "\n\n" + msg
        KMessageBox.information(AptUrlDialog(), summary, title)
        return True

    def yesNoQuestion(self, summary, msg, title="", default='no'):
        self._get_dialog('', summary, msg,
                             buttons=KDialog.Yes | KDialog.No)
        self.d.setWindowTitle(title)
        res = self.dialog.exec_()
        if res != KDialog.Accepted:
            return False
        return True

    # specific dialogs
    def askEnableChannel(self, channel, channel_info_html):
        summary = "<h2>" + _("Enable additional software channel") + "</h2>"
        msg = _("Do you want to enable the following "
                "software channel: '%s'?") % channel
        self._get_dialog('', summary, msg,
                             buttons=KDialog.Yes | KDialog.No)
        webview = QWebView()
        webview.setHtml(channel_info_html)
        webview.setFixedSize(400,200)
        self.d.vlayout_right.addWidget(webview)
        res = self.dialog.exec_()
        if res != KDialog.Accepted:
            return False
        return True

    def doEnableSection(self, sections):
        cmd = ["kdesudo",
               "--",
               "software-properties-kde",
               "--enable-component", "%s" % ' '.join(sections)]
        try:
            output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
        except OSError, e:
            print >>sys.stderr, "Execution failed:", e
            return True
        # FIXME: Very ugly, but kdesudo doesn't return the correct exit states
        print output
        if not output.startswith("Enabled the "):
            return False
        return True


    def doEnableChannel(self, channelpath, channelkey):
        cmd = ["kdesudo",
               "--",
               "install", "--mode=644","--owner=0",channelpath,
               apt_pkg.Config.FindDir("Dir::Etc::sourceparts")]
        res=subprocess.call(cmd)
        if not res == 0:
            return False
        # install the key as well
        if os.path.exists(channelkey):
            cmd = ["kdesudo",
                   "--",
                   "apt-key", "add",channelkey]
            res=subprocess.call(cmd)
            if not res == 0:
                return False
        return True

    def askInstallPackage(self, package, summary, description, homepage):
        header = "<h2>" + _("Install additional software?") + "</h2>"
        body = _("Do you want to install package '%s'?") % package
        desc = "%s\n\n%s" % (summary, Helpers.format_description(description))

        self.d.header_label.setText(header)
        self.d.body_label.setText(body)
        #self.description_edit.show()
        #self.description_edit.setText(desc)

        self.dialog.setButtons(KDialog.ButtonCode(KDialog.Yes | KDialog.No))

        res = self.dialog.exec_()
        if res != KDialog.Accepted:
            return False
        return True

    # progress etc
    def doUpdate(self):
        p = subprocess.Popen(['qapt-batch',
                              '--attach', str(self.dialog.winId()),
                              '--update'
                              ])
        self._wait_for_install_package(p)

    def doInstall(self, apturl):
        p = subprocess.Popen(['qapt-batch',
                              '--attach', str(self.dialog.winId()),
                              '--install',
                              apturl.package
                              ])
        self._wait_for_install_package(p)
        return True

    # helpers
    def _wait_for_p(self, p, lock):
        " helper for the thread to wait for process p to finish "
        p.wait()
        lock.release()

    def _wait_for_install_package(self, p):
        # wait for qapt-batch
        lock = thread.allocate_lock()
        lock.acquire()
        thread.start_new_thread(self._wait_for_p, (p, lock))

        while lock.locked():
            time.sleep(0.01)
        return True


if __name__ == "__main__":
    ui = KdeUI()
    ui.error("foo","bar")

# kate: space-indent on; indent-width 4; mixedindent off; indent-mode python;