Beispiel #1
0
def __removeFile(path):
    try:
        remove(path)
    except OSError, e:
        print >> stderr, e
        d = errorDialog("Error Deleting File...", str(e))
        d.spawn()
Beispiel #2
0
def __removeDirectory(path):
    try:
        rmtree(path)
    except OSError, e:
        print >> stderr, e
        d = errorDialog("Error Deleting Directory...", str(e))
        d.spawn()
Beispiel #3
0
def __removeDirectory(path):
    try:
        rmtree(path)
    except OSError, e:
        print >>stderr, e
        d = errorDialog("Error Deleting Directory...", str(e))
        d.spawn()
Beispiel #4
0
def __saveFile(file):
    """ Private method to write file to desk """
    # Save the file
    print "Attempting to save " + file.path
    try:
        f=open(file.path, 'w')
        datalist = file.data
        for row in datalist:
            if row[0] is not None:
                c1 = row[0]
            else:
                c1 = ""
            if row[1] is not None:
                c2 = row[1]
            else:
                c2 = ""
            if row[0].strip().startswith("#"):
                f.write(c1 + c2 + "\n")
            else:
                f.write(c1 + " " + c2 + "\n")
        f.close()
        __fileSaved(file)
    except IOError, e:
        print >>stderr, "Error saving: ", e
        d = errorDialog("Error Saving...", str(e))
        d.spawn()
Beispiel #5
0
def __removeFile(path):
    try:
        remove(path)
    except OSError,e:
        print >>stderr,e
        d = errorDialog("Error Deleting File...", str(e))
        d.spawn()
Beispiel #6
0
def __writeRenamedFile(oldFile, newFile):
    """ Performs the actual renaming of the file """
    try:
        rename(oldFile, newFile)
        print oldFile + " renamed to " + newFile
    except OSError, e:
        print >> stderr, "Rename: ", e
        d = errorDialog("Error Renaming...", str(e))
        d.spawn()
Beispiel #7
0
def __writeRenamedFile(oldFile, newFile):
    """ Performs the actual renaming of the file """
    try:
        rename(oldFile, newFile)
        print oldFile + " renamed to " + newFile
    except OSError, e:
        print >> stderr, "Rename: ", e
        d = errorDialog("Error Renaming...", str(e))
        d.spawn()
Beispiel #8
0
def ensureNotModified(msg):
    """ Ensure no files have been modified before proceeding, returns True if
    nothing is modified. If false a dialog is presented to the user """
    if hasModified():
        #inform user to save
        d = errorDialog("Unsaved Files Found...", msg) 
        d.spawn()
        return False
    else:
        return True
Beispiel #9
0
def __saveToDisk(nFile):
    print "Saving new file: " + nFile
    try:
        f=open(nFile, 'w')
        f.write("# " + nFile + "\n")
        f.write("# Created by GPytage\n")
        f.close
    except IOError, e:
        print >>stderr, e
        d = errorDialog("Error Creating File...", str(e))
        d.spawn()
Beispiel #10
0
def __saveToDisk(nFile):
    print "Saving new file: " + nFile
    try:
        f = open(nFile, 'w')
        f.write("# " + nFile + "\n")
        f.write("# Created by GPytage\n")
        f.close
    except IOError, e:
        print >> stderr, e
        d = errorDialog("Error Creating File...", str(e))
        d.spawn()
Beispiel #11
0
    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        self.process = QtCore.QProcess()

        dock = QtWidgets.QDockWidget(self.tr(getLanguage_left_panel_title()),
                                     self)
        # The dock be non movable, non closable and non floatable by the user.
        dock.setFeatures(QtWidgets.QDockWidget.NoDockWidgetFeatures)
        dock.font().setBold(True)
        #		dock.setFont( QtGui.QFont(dock.font()) )
        self.contentsWidget = QtWidgets.QListWidget(dock)
        self.contentsWidget.setSpacing(1)
        self.contentsWidget.setAlternatingRowColors(True)
        self.contentsWidget.setIconSize(QtCore.QSize(32, 32))
        self.textBrowser = QtWidgets.QTextBrowser()
        self.textBrowser.setOpenLinks(False)
        self.setCentralWidget(self.textBrowser)
        # When an URL is clicked in the central widget (text widget),
        # the corresponding program is launched
        self.textBrowser.anchorClicked.connect(self.launchProgram)
        # When the item (category) in the list widget is changed we change the
        # page seen in the text browser, that will include information taken from
        # the .desktop files in that category (folder in CONFIG_DIR).
        self.contentsWidget.currentItemChanged[QListWidgetItem,
                                               QListWidgetItem].connect(
                                                   self.changePage)
        # initialize (populates) the main window
        # This populates the dock with the list of categories
        self.initContentsWidget()
        # Set the initially  highligted category to be the first one.
        self.contentsWidget.setCurrentRow(0)
        # set the widget for the dock widget to the list of categories
        # whose we just defined the layout in initContentsWidget.
        # This implicitely shows (displays) the widget as the dock widget
        # was not yet visible
        dock.setWidget(self.contentsWidget)
        helpButton = QtWidgets.QPushButton(
            QtGui.QIcon("/usr/share/qcontrolcenter/icons/info.png"), "")
        quitButton = QtWidgets.QPushButton(
            QtGui.QIcon("/usr/share/qcontrolcenter/icons/exit.png"), "")
        self.statusBar().addPermanentWidget(helpButton, 0)
        self.statusBar().addPermanentWidget(quitButton, 0)
        helpButton.clicked.connect(self.showAbout)
        quitButton.clicked.connect(self.close)
        self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, dock)
        self.setWindowTitle(self.tr(getWindowTitle()))
        self.setWindowIcon(QtGui.QIcon("icons/arch-logo.png"))
        self.setMinimumSize(640, 480)
        if not os.path.exists(CONFIG_DIR):
            if not os.path.exists('/etc/skel/.qcontrolcenter'):
                errorDlg = errorDialog(self)
                errorDlg.show()
Beispiel #12
0
 def __scanFileContents(self, filepath):
     """ Return data in specified file in a list of a list [[col1, col2]]"""
     data = [] #list of list: eg [['python','x86']]
     try:
         f = open(filepath, 'r')
         contents = f.readlines()
         f.close()
     except IOError, e: #needed or everything breaks
         contents = None
         print >>stderr, e
         from errorDialog import errorDialog
         d = errorDialog("Error Reading File...", str(e))
         d.spawn()
         return data