def __init__(self, section=None, files=[]):
     deprecated('ConfigurationOrig class is deprecated')
     if not files:
         raise RuntimeError, 'need a list of files'
     object.__init__(self)
     self.__cfg__ = Configure(files=files)
     self.change(section)
Exemple #2
0
def runlog(command, destroylog=False,
           keeprunning=False, logvar='LOGFILE'):
    """This function will run a command and write all
    output to a logfile.  This function is likely
    to be deprecated.  It was only called from paella,
    and now paella has it's own runlog function.
    """
    from useless import deprecated
    deprecated("runlog is deprecated")
    logfile = os.environ[logvar]
    if isfile(logfile) and destroylog:
        os.remove(logfile)
    sysstream = dict(in_=sys.stdin, out=sys.stdout, err=sys.stderr)
    newstream = dict(in_=file('/dev/null'),
                     out=file(logfile, 'a'),
                     err=file(logfile, 'a+', 0))
    backup = {}
    for stream  in sysstream:
        backup[stream] = [os.dup(sysstream[stream].fileno()),
                          sysstream[stream].fileno()]
    for stream  in sysstream:
        os.dup2(newstream[stream].fileno(), backup[stream][1])
    
    run = os.system(command)
    
    if run and not keeprunning:
        raise RuntimeError, 'error in command %s , check %s' % (command, logfile)
    for stream in sysstream:
        os.dup2(backup[stream][0], backup[stream][1])
    for stream in newstream:
        newstream[stream].close()
    for stream in backup:
        os.close(backup[stream][0])
    return run
 def __init__(self, dsn, name, parent=None, objname=None):
     deprecated('useless.kdedb.BaseDatabase is deprecated')
     QSqlDatabase.__init__(self, 'QPSQL7', name, parent, objname)
     if hasattr(dsn, 'items'): #if dsn is dictionary
         self.conn = BasicConnection(**dsn)
         self.setDatabaseName(dsn['dbname'])
         self.setHostName(dsn['host'])
         self.dbuser = dsn['user']
     else: #else a conn was passed as dsn
         self.conn = dsn
         self.setDatabaseName(self.conn.conn.db)
         self.setHostName(self.conn.conn.host)
         self.dbuser = self.conn.conn.user
     self.setUserName(self.dbuser)
     self.stmt = Statement()
     self.mcursor = StatementCursor(self.conn)
Exemple #4
0
 def run_process_templates(self):
     templates = self.helper.templates
     num = len(templates)
     stmt = 'in run_process_templates, there are %d templates' % num
     stmt = '%s for trait %s' % (stmt, self.helper.trait)
     self.log.info(stmt)
     for t in templates:
         if t.template == 'var/cache/debconf/config.dat':
             msg = "using /var/cache/debconf/config.dat is now deprecated"
             deprecated(msg)
             self.log.warn(msg)
             self.log.info('Installing Debconf template ...')
             self.helper.install_debconf_template(t)
         elif t.template == 'debconf':
             self.log.info('Found debconf selections')
             self.helper.set_debconf_selections(t)
         else:
             text = self.helper.make_template(t)
             self.helper.install_template(t, text)
         # a hacky way to configure debconf
         if t.template == 'root/paella-debconf.sh':
             self.log.info('Running paella-debconf.sh script ...')
             retval = self.helper.chroot('/root/paella-debconf.sh', failure_suppressed=True)
             # sometimes this script returns 128 and can't be reproduced reliably
             # so we try running it again, until we have no 128 returned
             if retval == 128:
                 count = 0
                 while retval == 128:
                     count += 1
                     if count < 20:
                         self.log.info('/root/paella-debconf.sh returned 128, running again')
                         # this time we will fail on 128
                         retval = self.helper.chroot('/root/paella-debconf.sh',
                                                     failure_suppressed=True)
                     else:
                         raise InstallDebconfError, 'Too many attempts to run debconf script'
             elif retval and retval != 128:
                 msg = "problem running debconf script, returned %d" % retval
                 raise InstallDebconfError, msg
             # rename script
             filename = self.target / 'root/paella-debconf.sh'
             newname = self.target / 'root/%s-paella-debconf.sh' % self.helper.trait
             filename.rename(newname)
Exemple #5
0
 def set_logfile(self, logfile):
     deprecated("set_logfile is deprecated, use set_logger instead")
     self.set_logger(filename=logfile)
     self.logfile = path(logfile)
 def __init__(self, id='BaseObject'):
     deprecated('useless.kdedb.BaseObject is deprecated')
     DCOPExObj.__init__(self, id)
     self.addMethod('QString helloworld()', self.helloworld)
     self.addMethod('BaseDatabase getdb()', self.getdb)
Exemple #7
0
 def set_logfile(self, logfile):
     deprecated("set_logfile is deprecated, use set_logger instead")
     self.set_logger(filename=logfile)
     self.logfile = path(logfile)
Exemple #8
0
from qt import QCheckBox
from qt import QVBoxLayout

from kdecore import KConfigDialogManager
from kdecore import KAboutData
from kdeui import KMainWindow, KEdit, KPushButton
from kdeui import KMessageBox, KAboutDialog
from kdeui import KConfigDialog, KListView
from kdeui import KDialogBase, KLineEdit
from kdeui import KTextBrowser, KPopupMenu
from kdeui import KStdAction
from kdeui import KTabWidget, KActionSelector
from kdeui import KComboBox

from useless import deprecated
deprecated("useless.kbase.gui shouldn't be imported, it needs splitting up")


class MimeSources(QMimeSourceFactory):
    def __init__(self):
        QMimeSourceFactory.__init__(self)
        self.addFilePath('/usr/share/wallpapers')

class MainWindow(KMainWindow):
    def __init__(self, parent, name='MainWindow'):
        KMainWindow.__init__(self, parent, name)
        self.initActions()
        self.initMenus()
        if hasattr(self, 'initToolbar'):
            self.initToolbar()
Exemple #9
0
from kdeui import KDialogBase, KLineEdit
from kdeui import KMainWindow, KTextBrowser
from kdeui import KStdAction, KMessageBox
from kdeui import KListViewItem
from kdeui import KListView, KStdGuiItem
from kdeui import KPushButton, KStatusBar
from kdeui import KColorButton

from useless import deprecated
from useless.base import NoExistError
from useless.sqlgen.clause import Eq, In

from useless.kbase.gui import MainWindow, MimeSources
from useless.kbase.gui import SimpleRecord, SimpleRecordDialog

deprecated('useless.kdedb.gui should not be used')



class SimpleWindow(MainWindow):
    def __init__(self, app, parent, name):
        MainWindow.__init__(self, parent, name)
        self.app = app
        self.db = app.db
        
class BaseManagerWidget(SimpleWindow):
    def __init__(self, app, parent, view, name):
        SimpleWindow.__init__(self, app, parent, name)
        self.mainView = QSplitter(self, 'main view')
        self.listView = KListView(self.mainView)
        #view is some sort of display widget that requires db
from operator import and_

from qtsql import QSqlDatabase, QSqlDriver
from dcopexport import DCOPExObj


from useless import deprecated
from useless.base import NoExistError
from useless.sqlgen.clause import Eq, In
from useless.sqlgen.statement import Statement
from useless.db.lowlevel import BasicConnection
from useless.db.midlevel import StatementCursor

deprecated('useless.kdb is deprecated - do not import')

class BaseDriver(QSqlDriver):
    def __init__(self, parent=None, name=None):
        self.stmt = Statement()
        QSqlDriver.__init__(self, parent=parent, name=name)

class BaseDatabase(QSqlDatabase):
    def __init__(self, dsn, name, parent=None, objname=None):
        deprecated('useless.kdb.BaseDatabase is deprecated')
        QSqlDatabase.__init__(self, 'QPSQL7', name, parent, objname)
        if hasattr(dsn, 'items'): #if dsn is dictionary
            self.conn = BasicConnection(**dsn)
            self.setDatabaseName(dsn['dbname'])
            self.setHostName(dsn['host'])
            self.dbuser = dsn['user']
        else: #else a conn was passed as dsn
            self.conn = dsn
from useless import deprecated
deprecated('useless.kdebase.xmlgen is deprecated')

from xml.dom.minidom import Element, Text

class BaseElement(Element):
    def __init__(self, tagname, **atts):
        Element.__init__(self, tagname)
        self.setAttributes(**atts)
        
    def setAttributes(self, **atts):
        for k,v in atts.items():
            if k == '_node':
                self.appendChild(v)
            elif k == '_text':
                self._appendText(v)
            else:
                self.setAttribute(k, str(v))

    def _appendText(self, text):
        elementd = Text()
        if type(text) == str:
            lines = text.split('\n')
            if len(lines) > 1:
                for line in lines:
                    e = Text()
                    e.data = line
                    self.appendChild(e)
                    self.appendChild(BaseElement('br'))
            else:
                elementd.data = text
 def __init__(self, *args):
     deprecated('Use of ExistsError is deprecated use AlreadyExistsError instead')
     AlreadyExistsError.__init__(self, *args)
 def __init__(self, *args):
     deprecated('Use of Error class is now deprecated')
     BaseError.__init__(self, *args)
from useless import deprecated

deprecated("useless.kbase is deprecated - do not import")
def cj_fields(fields):
    deprecated("cj_fields is deprecated use handle_fieldlist instead")
    if type(fields) == list:
        return ", ".join(fields)
    else:
        return fields