Exemplo n.º 1
0
 def stop(self):
     """Userver stop"""
     super(UServer, self).stop()
     PluginManager.getManager().unloadAllPlugins()
     if self.isEnableSocket:
         self.sock.close()
     ConfManager.getManager().save()
Exemplo n.º 2
0
 def stop(self):
     """Userver stop"""
     super(UServer, self).stop()
     PluginManager.getManager().unloadAllPlugins()
     if self.isEnableSocket:
         self.sock.close()
     ConfManager.getManager().save()
Exemplo n.º 3
0
    def closeEvent(self, event):
        """override close event"""
        if self.trayIcon.isVisible():
            self.hide()
            event.ignore()

        ConfManager.getManager().save()
        logging.debug('[%s] is closed, window is hide, configuration is saved', self.getName())
Exemplo n.º 4
0
    def closeEvent(self, event):
        """override close event"""
        if self.trayIcon.isVisible():
            self.hide()
            event.ignore()

        ConfManager.getManager().save()
        logging.debug('[%s] is closed, window is hide, configuration is saved',
                      self.getName())
Exemplo n.º 5
0
    def show(self):
        """ovrride parent show method"""
        super(UniFileSyncUI, self).show()

        #Init status bar
        stBarConf = ConfManager.getManager().getValue('UI', 'statusbar')
        self.statusbar.showMessage(stBarConf['messages']['init'])

        #set UI label
        username = ConfManager.getManager().getValue('UI', 'username')
        self.ui.nameLabel.setText(username)
Exemplo n.º 6
0
    def show(self):
        """ovrride parent show method"""
        super(UniFileSyncUI, self).show()

        #Init status bar
        stBarConf = ConfManager.getManager().getValue('UI', 'statusbar')
        self.statusbar.showMessage(stBarConf['messages']['init'])

        #set UI label
        username = ConfManager.getManager().getValue('UI', 'username')
        self.ui.nameLabel.setText(username)
Exemplo n.º 7
0
    def __init__(self, name=None):
        super(UniFileSyncUI, self).__init__()

        self.ui = Ui_UniFileSyncPop()
        self.ui.setupUi(self)

        self.setFixedSize(self.size())

        self.server = UServer('UServer')
        self.server.regSelfToBus()

        if name:
            self.setName(name)

        self.createActions()
        self.createTrayIcon()
        self.createStatusBar()

        qApp.setQuitOnLastWindowClosed(False)

        #connect the signal with slot
        self.connectUISlots(self.ui)
        #set UI label
        username = ConfManager.getManager().getValue('UI', 'username')
        self.ui.nameLabel.setText(username)

        #Start server immediately
        self.server.start()
        #self.server.getHandler('start')({'name': 'all'})
        msg = self.server.initMsg('start', None, MSG_UNIQUE_ID_T_CONTROLLER,
                                  False, {'name': 'all'})
        UMsgBus.getBus().send(msg)

        self.server.addCallBack(self.statusupdate)
        self.server.addCallBack(self.cloudinfoupdate)

        #setup list
        self.setupFolderList(self.ui.folderList)
        self.setupPluginList(self.ui.pluginList)
        self.setupNetworkConf()

        #Init status bar
        stBarConf = ConfManager.getManager().getValue('UI', 'statusbar')
        self.statusbar.showMessage(stBarConf['messages']['init'])

        #Init system icon
        self.trayIcon.show()
        self.showTrayIconMessage()
Exemplo n.º 8
0
    def __init__(self, name=None):
        super(UniFileSyncUI, self).__init__()

        self.ui = Ui_UniFileSyncPop()
        self.ui.setupUi(self)

        self.setFixedSize(self.size())

        self.server = UServer('UServer')
        self.server.regSelfToBus()

        if name:
            self.setName(name)

        self.createActions()
        self.createTrayIcon()
        self.createStatusBar()

        qApp.setQuitOnLastWindowClosed(False)

        #connect the signal with slot
        self.connectUISlots(self.ui)
        #set UI label
        username = ConfManager.getManager().getValue('UI', 'username')
        self.ui.nameLabel.setText(username)

        #Start server immediately
        self.server.start()
        #self.server.getHandler('start')({'name': 'all'})
        msg = self.server.initMsg('start', None, MSG_UNIQUE_ID_T_CONTROLLER, False, {'name': 'all'})
        UMsgBus.getBus().send(msg)

        self.server.addCallBack(self.statusupdate)
        self.server.addCallBack(self.cloudinfoupdate)

        #setup list
        self.setupFolderList(self.ui.folderList)
        self.setupPluginList(self.ui.pluginList)
        self.setupNetworkConf()

        #Init status bar
        stBarConf = ConfManager.getManager().getValue('UI', 'statusbar')
        self.statusbar.showMessage(stBarConf['messages']['init'])

        #Init system icon
        self.trayIcon.show()
        self.showTrayIconMessage()
Exemplo n.º 9
0
 def setupFolderList(self, folderList):
     """setup folder list for showing"""
     fts = ConfManager.getManager().getValue('common', 'folders')
     i = 0
     for ft in fts:
         flistItem = QListWidgetItem(QIcon('icon/folder.png'), ft, folderList)
         folderList.insertItem(i, flistItem)
         i += 1
Exemplo n.º 10
0
 def setupPluginList(self, pluginList):
     """setup plugin list from configuration file"""
     fts = ConfManager.getManager().getValue('common', 'plugins')
     i = 0
     for ft in fts:
         flistItem = QListWidgetItem(QIcon('icon/plugin.png'), ft['name'], pluginList)
         pluginList.insertItem(i, flistItem)
         i += 1
Exemplo n.º 11
0
 def setupPluginList(self, pluginList):
     """setup plugin list from configuration file"""
     fts = ConfManager.getManager().getValue('common', 'plugins')
     i = 0
     for ft in fts:
         flistItem = QListWidgetItem(QIcon('icon/plugin.png'), ft['name'],
                                     pluginList)
         pluginList.insertItem(i, flistItem)
         i += 1
Exemplo n.º 12
0
 def setupFolderList(self, folderList):
     """setup folder list for showing"""
     fts = ConfManager.getManager().getValue('common', 'folders')
     i = 0
     for ft in fts:
         flistItem = QListWidgetItem(QIcon('icon/folder.png'), ft,
                                     folderList)
         folderList.insertItem(i, flistItem)
         i += 1
Exemplo n.º 13
0
    def configure(self):
        """server self configure when it is started"""
        register_openers()
        PluginManager.getManager().loadAllPlugins()
        confManager = ConfManager.getManager()
        proxy = confManager.getValue('common', 'network')

        if proxy['proxy'] != "" and proxy['proxy'] != None:
            param = {'http': 'http://%s' % proxy['proxy'], 'https': 'https://%s' % proxy['proxy'] }
            set_proxy(param)
            logging.debug('[%s]: set proxy server %s', self.getName(), proxy['proxy'])
Exemplo n.º 14
0
    def loadAllPlugins(self):
        """load all plugins from destant path"""
        p_paths = ConfManager.getManager().getPluginPaths()
        pluginList = ConfManager.getManager().getValue('common', 'plugins')

        for p in p_paths:
            logging.debug('[%s]: loadAllPlugins from %s', 'PluginManager', p)
            #TODO: __import__ the module into our script
            try:
                dirs = os.listdir(p)
                for d in dirs:
                    tmp = '%s%s%s' % (p, os.sep, d)
                    if os.path.isdir(tmp):
                        module_name = 'UniFileSync.plugins.%s' % d
                        module_path = '%s%s%sPlugin.py' % (tmp, os.sep, d)
                        imp.load_source('', module_path)
                        pl = {'name': d, 'path': module_path}
                        if pl not in pluginList:
                            pluginList.append(pl)

            except OSError as exc:
                logging.error('loadAllPlugins listdir error %d', OSError.errno)

        ConfManager.getManager().setValue('common', 'plugins', pluginList)
        logging.debug('[%s]: loadAllPlugins and save %s into configuration', 'PluginManager', pluginList)
        ConfManager.getManager().save()
Exemplo n.º 15
0
    def startHandler(self, param):
        """start handler for actors"""
        logging.debug('[%s]: startHandler with parm %s', self.getName(), param)

        if param['name']:
            name = param['name'].lower()
        else:
            name = ''
        res = E_OK

        watchpaths = ConfManager.getManager().getValue('common', 'folders')

        if name == 'all' or name == '':
            if self.cActor.isRunning or self.fsMonitor.isRunning:
                return E_ACTOR_ALIVE, None
            self.cActor.start()
            self.__startActors.append(self.cActor)
            self.fsMonitor.start()
            self.__startActors.append(self.fsMonitor)

            time.sleep(2)
            for w in watchpaths:
                self.watchHandler({'path': w, 'action': 'add'}, False)
                #logging.debug('[%s]: add watch path %s from configuration file', self.getName(), w)

        elif name == 'monitor':
            if self.fsMonitor.isRunning:
                return E_ACTOR_ALIVE, None
            self.fsMonitor.start()
            self.__startActors.append(self.fsMonitor)

            time.sleep(2)
            for w in watchpaths:
                self.watchHandler({'path': w, 'action': 'add'})
                logging.debug(
                    '[%s]: add watch path %s from configuration file',
                    self.getName(), w)

        elif name == 'cloud':
            if self.cActor.isRunning:
                return E_ACTOR_ALIVE, None
            self.cActor.start()
            self.__startActors.append(self.cActor)
        else:
            logging.error('[%s]: startHandler with name %s error',
                          self.getName(), param['name'])
            res = E_INVILD_PARAM

        return res, None
Exemplo n.º 16
0
    def configure(self):
        """server self configure when it is started"""
        register_openers()
        PluginManager.getManager().loadAllPlugins()
        confManager = ConfManager.getManager()
        proxy = confManager.getValue('common', 'network')

        if proxy['proxy'] != "" and proxy['proxy'] != None:
            param = {
                'http': 'http://%s' % proxy['proxy'],
                'https': 'https://%s' % proxy['proxy']
            }
            set_proxy(param)
            logging.debug('[%s]: set proxy server %s', self.getName(),
                          proxy['proxy'])
Exemplo n.º 17
0
    def startHandler(self, param):
        """start handler for actors"""
        logging.debug('[%s]: startHandler with parm %s', self.getName(), param);

        if param['name']:
            name = param['name'].lower()
        else:
            name = ''
        res = E_OK

        watchpaths = ConfManager.getManager().getValue('common', 'folders')

        if name == 'all' or name == '':
            if self.cActor.isRunning or self.fsMonitor.isRunning:
                return E_ACTOR_ALIVE, None
            self.cActor.start()
            self.__startActors.append(self.cActor)
            self.fsMonitor.start()
            self.__startActors.append(self.fsMonitor)

            time.sleep(2)
            for w in watchpaths:
                self.watchHandler({'path': w, 'action': 'add'}, False)
                #logging.debug('[%s]: add watch path %s from configuration file', self.getName(), w)

        elif name == 'monitor':
            if self.fsMonitor.isRunning:
                return E_ACTOR_ALIVE, None
            self.fsMonitor.start()
            self.__startActors.append(self.fsMonitor)

            time.sleep(2)
            for w in watchpaths:
                self.watchHandler({'path': w, 'action': 'add'})
                logging.debug('[%s]: add watch path %s from configuration file', self.getName(), w)

        elif name == 'cloud':
            if self.cActor.isRunning:
                return E_ACTOR_ALIVE, None
            self.cActor.start()
            self.__startActors.append(self.cActor)
        else:
            logging.error('[%s]: startHandler with name %s error', self.getName(), param['name'])
            res = E_INVILD_PARAM

        return res, None
Exemplo n.º 18
0
    def connBtnSlots(self, btn):
        """docstring for connBtnSlots"""
        if btn is self.ui.connBtn:
            if btn.text() == 'Connect':
                msg = self.server.initMsg('info', None, MSG_UNIQUE_ID_T_CONTROLLER, True, {'name': 'all'})
                UMsgBus.getBus().send(msg)
                #res, data = self.server.getHandler('info')({'name': 'all'})
                btn.setText('Connecting')
                #self.ui.infoLabel.setText(data)
                logging.debug('[%s]: Press Connect to getCloudInfo', self.getName())
            elif btn.text() == 'Disconnect':
                #self.server.getHandler('stop')({'name': 'all'})
                btn.setText('Connect')
                self.ui.infoLabel.setText('Cloud Disk is disconnected')

        elif btn is self.ui.addFolderBtn:
            fileDialog = QFileDialog(self)
            fileDialog.setWindowTitle('Select Folder')
            folderPath = fileDialog.getExistingDirectory()
            if folderPath != "":
                listItem = QListWidgetItem(QIcon('icon/folder.png'), folderPath, self.ui.folderList)
                pyStr = '%s' % folderPath
                logging.debug('[%s]: add folder path %s', self.getName(), pyStr)
                self.ui.folderList.insertItem(self.ui.folderList.count(), listItem)
                folderList = ConfManager.getManager().getValue('common', 'folders')
                folderList.append(pyStr)
                ConfManager.getManager().setValue('common', 'folders', folderList)
                #send watch dir request
                msg =  self.server.initMsg('watch', None, MSG_UNIQUE_ID_T_CONTROLLER, True, {'path': pyStr, 'action': 'add'})
                UMsgBus.getBus().send(msg)
                self.statusbar.showMessage('Adding watch path %s' % folderPath)

        elif btn is self.ui.rmFolderBtn:
            row = self.ui.folderList.currentRow()
            item = self.ui.folderList.currentItem()
            folderList = ConfManager.getManager().getValue('common', 'folders')
            self.statusbar.showMessage('Removing watch path %s' % item.text())
            pyStr = '%s' % item.text()
            folderList.remove(pyStr)
            ConfManager.getManager().setValue('common', 'folders', folderList)
            logging.debug('[%s]: remove item %d %s', self.getName(), row, item.text())
            msg =  self.server.initMsg('watch', None, MSG_UNIQUE_ID_T_CONTROLLER, True, {'path': pyStr, 'action': 'rm'})
            UMsgBus.getBus().send(msg)
            self.ui.folderList.takeItem(row)

        elif btn is self.ui.saveBtn:
            proxyConf = ConfManager.getManager().getValue('common', 'network')
            server = str(self.ui.proxyLineEdit.text())

            if server != "" and server != None:
                user = str(self.ui.proxyNameLineEdit.text())
                password = str(self.ui.proxyPwdLineEdit.text())
                logging.debug('[%s]: save server=>%s user=>%s password=>%s into configuration',
                              self.getName(), server, user, password)
                proxyConf['proxy'] = server
                proxyConf['user'] = user
                proxyConf['password'] = password
                ConfManager.getManager().setValue('common', 'network', proxyConf)
                msg =  self.server.initMsg('proxy', None, MSG_UNIQUE_ID_T_CONTROLLER, True,
                            {'http': 'http://%s' % server, 'https': 'https://%s' % server})
                UMsgBus.getBus().send(msg)
                self.statusbar.showMessage('Applying proxy %s' % server)

                ConfManager.getManager().save()

        elif btn is self.ui.resetBtn:
            proxyConf = ConfManager.getManager().getValue('common', 'network')
            server = proxyConf['proxy']
            user = proxyConf['user']
            password = proxyConf['password']
            port = proxyConf['port']

            self.ui.proxyLineEdit.setText(server)
            self.ui.proxyNameLineEdit.setText(user)
            self.ui.proxyPwdLineEdit.setText(password)
            self.ui.portLineEdit.setText(str(port))
            self.ui.serverEnableCheckBox.setCheckState(0)

        elif btn is self.ui.unloadBtn:
            row = self.ui.pluginList.currentRow()
            it = str(self.ui.pluginList.currentItem().text())
            logging.debug('[%s]: unload plugin name %s', self.getName(), it)
            self.statusbar.showMessage('Unloading plugin %s' % it)
            PluginManager.getManager().unload(it)
            self.ui.pluginList.takeItem(row)
            conf = ConfManager.getManager().getValue('common', 'plugins')
            for pc in conf:
                if pc['name'] == it:
                    conf.remove(pc)
            ConfManager.getManager().setValue('common', 'plugins', conf)

        elif btn is self.ui.reloadBtn:
            row = self.ui.pluginList.currentRow()
            it = str(self.ui.pluginList.currentItem().text())
            logging.debug('[%s]: reload plugin name %s', self.getName(), it)
            self.statusbar.showMessage('Reloading plugin %s' % it)
            PluginManager.getManager().reload(it)

        elif btn is self.ui.addPluginBtn:
            path = QFileDialog.getOpenFileName(self)
            PluginManager.getManager().loadPluginFromPath(str(path))

        elif btn is self.ui.syncFolderBtn:
            folder = str(self.ui.folderList.currentItem().text())
            msg =  self.server.initMsg('sync', None, MSG_UNIQUE_ID_T_CONTROLLER, True, {'path': str(folderPath), 'action': 'add'})
            UMsgBus.getBus().send(msg)
            self.statusbar.showMessage('Sync %s with cloud' % folder)
Exemplo n.º 19
0
    def connBtnSlots(self, btn):
        """docstring for connBtnSlots"""
        if btn is self.ui.connBtn:
            if btn.text() == 'Connect':
                msg = self.server.initMsg('info', None,
                                          MSG_UNIQUE_ID_T_CONTROLLER, True,
                                          {'name': 'all'})
                UMsgBus.getBus().send(msg)
                #res, data = self.server.getHandler('info')({'name': 'all'})
                btn.setText('Connecting')
                #self.ui.infoLabel.setText(data)
                logging.debug('[%s]: Press Connect to getCloudInfo',
                              self.getName())
            elif btn.text() == 'Disconnect':
                #self.server.getHandler('stop')({'name': 'all'})
                btn.setText('Connect')
                self.ui.infoLabel.setText('Cloud Disk is disconnected')

        elif btn is self.ui.addFolderBtn:
            fileDialog = QFileDialog(self)
            fileDialog.setWindowTitle('Select Folder')
            folderPath = fileDialog.getExistingDirectory()
            if folderPath != "":
                listItem = QListWidgetItem(QIcon('icon/folder.png'),
                                           folderPath, self.ui.folderList)
                pyStr = '%s' % folderPath
                logging.debug('[%s]: add folder path %s', self.getName(),
                              pyStr)
                self.ui.folderList.insertItem(self.ui.folderList.count(),
                                              listItem)
                folderList = ConfManager.getManager().getValue(
                    'common', 'folders')
                folderList.append(pyStr)
                ConfManager.getManager().setValue('common', 'folders',
                                                  folderList)
                #send watch dir request
                msg = self.server.initMsg('watch', None,
                                          MSG_UNIQUE_ID_T_CONTROLLER, True, {
                                              'path': pyStr,
                                              'action': 'add'
                                          })
                UMsgBus.getBus().send(msg)
                self.statusbar.showMessage('Adding watch path %s' % folderPath)

        elif btn is self.ui.rmFolderBtn:
            row = self.ui.folderList.currentRow()
            item = self.ui.folderList.currentItem()
            folderList = ConfManager.getManager().getValue('common', 'folders')
            self.statusbar.showMessage('Removing watch path %s' % item.text())
            pyStr = '%s' % item.text()
            folderList.remove(pyStr)
            ConfManager.getManager().setValue('common', 'folders', folderList)
            logging.debug('[%s]: remove item %d %s', self.getName(), row,
                          item.text())
            msg = self.server.initMsg('watch', None,
                                      MSG_UNIQUE_ID_T_CONTROLLER, True, {
                                          'path': pyStr,
                                          'action': 'rm'
                                      })
            UMsgBus.getBus().send(msg)
            self.ui.folderList.takeItem(row)

        elif btn is self.ui.saveBtn:
            proxyConf = ConfManager.getManager().getValue('common', 'network')
            server = str(self.ui.proxyLineEdit.text())

            if server != "" and server != None:
                user = str(self.ui.proxyNameLineEdit.text())
                password = str(self.ui.proxyPwdLineEdit.text())
                logging.debug(
                    '[%s]: save server=>%s user=>%s password=>%s into configuration',
                    self.getName(), server, user, password)
                proxyConf['proxy'] = server
                proxyConf['user'] = user
                proxyConf['password'] = password
                ConfManager.getManager().setValue('common', 'network',
                                                  proxyConf)
                msg = self.server.initMsg('proxy', None,
                                          MSG_UNIQUE_ID_T_CONTROLLER, True, {
                                              'http': 'http://%s' % server,
                                              'https': 'https://%s' % server
                                          })
                UMsgBus.getBus().send(msg)
                self.statusbar.showMessage('Applying proxy %s' % server)

                ConfManager.getManager().save()

        elif btn is self.ui.resetBtn:
            proxyConf = ConfManager.getManager().getValue('common', 'network')
            server = proxyConf['proxy']
            user = proxyConf['user']
            password = proxyConf['password']
            port = proxyConf['port']

            self.ui.proxyLineEdit.setText(server)
            self.ui.proxyNameLineEdit.setText(user)
            self.ui.proxyPwdLineEdit.setText(password)
            self.ui.portLineEdit.setText(str(port))
            self.ui.serverEnableCheckBox.setCheckState(0)

        elif btn is self.ui.unloadBtn:
            row = self.ui.pluginList.currentRow()
            it = str(self.ui.pluginList.currentItem().text())
            logging.debug('[%s]: unload plugin name %s', self.getName(), it)
            self.statusbar.showMessage('Unloading plugin %s' % it)
            PluginManager.getManager().unload(it)
            self.ui.pluginList.takeItem(row)
            conf = ConfManager.getManager().getValue('common', 'plugins')
            for pc in conf:
                if pc['name'] == it:
                    conf.remove(pc)
            ConfManager.getManager().setValue('common', 'plugins', conf)

        elif btn is self.ui.reloadBtn:
            row = self.ui.pluginList.currentRow()
            it = str(self.ui.pluginList.currentItem().text())
            logging.debug('[%s]: reload plugin name %s', self.getName(), it)
            self.statusbar.showMessage('Reloading plugin %s' % it)
            PluginManager.getManager().reload(it)

        elif btn is self.ui.addPluginBtn:
            path = QFileDialog.getOpenFileName(self)
            PluginManager.getManager().loadPluginFromPath(str(path))

        elif btn is self.ui.syncFolderBtn:
            folder = str(self.ui.folderList.currentItem().text())
            msg = self.server.initMsg('sync', None, MSG_UNIQUE_ID_T_CONTROLLER,
                                      True, {
                                          'path': str(folderPath),
                                          'action': 'add'
                                      })
            UMsgBus.getBus().send(msg)
            self.statusbar.showMessage('Sync %s with cloud' % folder)
Exemplo n.º 20
0
 def setupNetworkConf(self):
     """setup network configuration into UI"""
     conf = ConfManager.getManager().getValue('common', 'network')
     self.ui.proxyLineEdit.setText(conf['proxy'])
     self.ui.portLineEdit.setText("%s" % conf['port'])
Exemplo n.º 21
0
    def showTrayIconMessage(self):
        """show tray icon message"""
        conf = ConfManager.getManager().getValue('UI', 'trayicon')
        popup = conf['popup']

        self.trayIcon.showMessage(popup['title'], popup['message'])
Exemplo n.º 22
0
app.setQuitOnLastWindowClosed(False)

m = QWidget()
d = QMainWindow(m)

t = QSystemTrayIcon(m)
t.setIcon(QIcon('icon/tray.png'))

ui = Ui_UniFileSyncPop()
ui.setupUi(d)

d.setFixedSize(d.size())

req = {'type': 'request'}

confManager = ConfManager.getManager()

fts = confManager.getValue('common', 'folders')

ui.nameLabel.setText(confManager.getValue('UI', 'username'))

i = 0
for ft in fts:
    flistItem = QListWidgetItem(QIcon('icon/folder.png'), ft, ui.folderList)
    ui.folderList.insertItem(i, flistItem)
    i += 1

statusBar = QStatusBar(d)
#print confManager.getValue('UI', 'window')
statusBar.showMessage(
    confManager.getValue('UI', 'statusbar')['messages']['init'])
Exemplo n.º 23
0
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import os
import logging

from UniFileSync.lib.common.ConfManager import ConfManager

logging.basicConfig(level=logging.DEBUG,
                format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
                datefmt='%a, %d %b %Y %H:%M:%S',
                filename= ConfManager.getManager().getUserLogPath() + os.sep + 'UniFileSync.log',
                filemode= 'a')

#################################################################################################
#定义一个StreamHandler,将INFO级别或更高的日志信息打印到标准错误,并将其添加到当前的日志处理对象#
console = logging.StreamHandler()
console.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s %(filename)s: %(levelname)-8s %(message)s')
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)
################################################################################################

logging.info('[UniFileSync] Start a new logging =========')
Exemplo n.º 24
0
 def setupNetworkConf(self):
     """setup network configuration into UI"""
     conf = ConfManager.getManager().getValue('common', 'network')
     self.ui.proxyLineEdit.setText(conf['proxy'])
     self.ui.portLineEdit.setText("%s" % conf['port'])
Exemplo n.º 25
0
m = QWidget()
d = QMainWindow(m)

t = QSystemTrayIcon(m)
t.setIcon(QIcon("icon/tray.png"))

ui = Ui_UniFileSyncPop()
ui.setupUi(d)

d.setFixedSize(d.size())


req = {"type": "request"}

confManager = ConfManager.getManager()

fts = confManager.getValue("common", "folders")

ui.nameLabel.setText(confManager.getValue("UI", "username"))

i = 0
for ft in fts:
    flistItem = QListWidgetItem(QIcon("icon/folder.png"), ft, ui.folderList)
    ui.folderList.insertItem(i, flistItem)
    i += 1

statusBar = QStatusBar(d)
# print confManager.getValue('UI', 'window')
statusBar.showMessage(confManager.getValue("UI", "statusbar")["messages"]["init"])
d.setStatusBar(statusBar)
Exemplo n.º 26
0
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import os
import logging

from UniFileSync.lib.common.ConfManager import ConfManager

logging.basicConfig(
    level=logging.DEBUG,
    format=
    '%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
    datefmt='%a, %d %b %Y %H:%M:%S',
    filename=ConfManager.getManager().getUserLogPath() + os.sep +
    'UniFileSync.log',
    filemode='a')

#################################################################################################
#定义一个StreamHandler,将INFO级别或更高的日志信息打印到标准错误,并将其添加到当前的日志处理对象#
console = logging.StreamHandler()
console.setLevel(logging.DEBUG)
formatter = logging.Formatter(
    '%(asctime)s %(filename)s: %(levelname)-8s %(message)s')
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)
################################################################################################

logging.info('[UniFileSync] Start a new logging =========')
Exemplo n.º 27
0
    def showTrayIconMessage(self):
        """show tray icon message"""
        conf = ConfManager.getManager().getValue('UI', 'trayicon')
        popup = conf['popup']

        self.trayIcon.showMessage(popup['title'], popup['message'])