Esempio n. 1
0
 def clickCheckBox(self, checkBox, name):
     if checkBox.isChecked():
         STCLogger().i('select ' + name)
         self.selectCheckBoxInfo(name)
     else:
         STCLogger().i('cancel ' + name)
         self.cancelCheckBoxInfo(name)
 def clearAllCaches():
     if XulDebugServerHelper.HOST == '':
         raise ValueError('Host is empty!')
     else:
         try:
             url = XulDebugServerHelper.HOST + XulDebugServerHelper.__CLEAR_ALL_CACHES
             http = urllib3.PoolManager()
             STCLogger().i("clearAllCaches = " + url)
             r = http.request('GET', url)
         except Exception as e:
             STCLogger().e(e)
             return
         return r
 def getAllSelector():
     if XulDebugServerHelper.HOST == '':
         raise ValueError('Host is empty!')
     else:
         try:
             url = XulDebugServerHelper.HOST + XulDebugServerHelper.__GET_SELECTOR
             http = urllib3.PoolManager()
             STCLogger().i("getAllSelector = " + url)
             r = http.request('GET', url)
         except Exception as e:
             STCLogger().e(e)
             return
         return r
 def focusChooseItemUrl(id):
     if XulDebugServerHelper.HOST == '':
         raise ValueError('Host is empty!')
     else:
         try:
             url = XulDebugServerHelper.HOST + XulDebugServerHelper.__REQUEST_FOCUS + '/' + id
             http = urllib3.PoolManager()
             STCLogger().i("focusChooseItemUrl = " + url)
             r = http.request('GET', url)
         except Exception as e:
             STCLogger().e(e)
             return
         return r
 def fireItemEvent(action, id):
     if XulDebugServerHelper.HOST == '':
         raise ValueError('Host is empty!')
     else:
         try:
             url = XulDebugServerHelper.HOST + quote(
                 XulDebugServerHelper.__FIRE_EVENT + '/' + id + '/' +
                 action)
             http = urllib3.PoolManager()
             STCLogger().i("fireItemEvent = " + url)
             r = http.request('GET', url)
         except Exception as e:
             STCLogger().e(e)
             return r
 def updateClassUrl(type, id, className):
     if XulDebugServerHelper.HOST == '':
         raise ValueError('Host is empty!')
     else:
         try:
             url = XulDebugServerHelper.HOST + quote(type + '/' + id + '/' +
                                                     className)
             http = urllib3.PoolManager()
             STCLogger().i("updateClassUrl = " + url)
             r = http.request('GET', url)
         except Exception as e:
             STCLogger().e(e)
             return
         return r
    def __init__(self, window, parent=None):
        self.mainWindow = window
        try:
            super(FavoriteTreeView, self).__init__(parent)
            self.treeModel = QStandardItemModel()
            self.favorites = QStandardItem(ROOT_FAVORITES)
            self.buildFavoritesTree()
            self.providerQueryHistory = QStandardItem(
                ROOT_PROVIDERQUERYHISTORY)
            self.buildQueryHistory()
            self.treeModel.appendColumn(
                [self.favorites, self.providerQueryHistory])
            self.treeModel.setHeaderData(0, Qt.Horizontal, 'Record')

            self.setModel(self.treeModel)
            self.setEditTriggers(QAbstractItemView.NoEditTriggers)
            self.setContextMenuPolicy(Qt.CustomContextMenu)
            self.customContextMenuRequested.connect(self.openContextMenu)
            self.doubleClicked.connect(self.onTreeItemDoubleClicked)
            self.setSelectionBehavior(QAbstractItemView.SelectItems)
            # 设置该控件可以多选
            self.setSelectionMode(QAbstractItemView.ExtendedSelection)
            # self.clicked.connect(self.clickState)
        except Exception as e:
            STCLogger().e(e)
 def add2Favorites(self, item):
     if item.type == ITEM_TYPE_HISTORY:
         dateTime = time.strftime("%Y/%m/%d %H:%M:%S",
                                  time.localtime(time.time()))
         FavoriteDB.insertFavorites(item.name, item.url, dateTime, item.id)
         STCLogger().i('the history record add to DataBase of favorites :' +
                       item.url)
         self.updateTree()
Esempio n. 9
0
 def findNodeById(id, xml):
     root = etree.fromstring(xml)
     # print(etree.tostring(root, pretty_print=True).decode('utf-8'))
     try:
         list = root.xpath("//*[@id=%s]" % id)
     except Exception as e:
         STCLogger().e(e)
     return list[0]
Esempio n. 10
0
    def initMenuBar(self):
        menuBar = self.menuBar()
        fileMenu = menuBar.addMenu('File')
        disConnectAction = QAction(IconTool.buildQIcon('disconnect.png'),
                                   '&Disconnect', self)
        disConnectAction.setShortcut('Ctrl+D')
        disConnectAction.setShortcutContext(Qt.ApplicationShortcut)
        disConnectAction.triggered.connect(self.restartProgram)
        settingAction = QAction(IconTool.buildQIcon('setting.png'),
                                '&Setting...', self)
        settingAction.setShortcut('Ctrl+Shift+S')
        settingAction.setShortcutContext(Qt.ApplicationShortcut)
        settingAction.triggered.connect(lambda: STCLogger().d('setting'))
        clearCacheAction = QAction(IconTool.buildQIcon('clearCache.png'),
                                   '&ClearCache', self)
        clearCacheAction.setShortcut('Ctrl+Alt+C')
        clearCacheAction.setShortcutContext(Qt.ApplicationShortcut)
        clearCacheAction.triggered.connect(self.clearCache)
        clearSearchHistoryAction = QAction(
            IconTool.buildQIcon('clearCache.png'), '&ClearSearchHistory', self)
        clearSearchHistoryAction.triggered.connect(self.clearSearchHistory)
        settingLogPathAction = QAction(IconTool.buildQIcon('path.png'),
                                       '&LogPath', self)
        settingLogPathAction.triggered.connect(self.setLogPath)
        fileMenu.addAction(disConnectAction)
        fileMenu.addAction(clearCacheAction)
        fileMenu.addAction(settingLogPathAction)
        fileMenu.addAction(clearSearchHistoryAction)
        # fileMenu.addAction(settingAction)
        # fileMenu.addAction(showLogAction)

        # settingAction.triggered.connect(self.openSettingWindow)

        editMenu = menuBar.addMenu('Edit')
        findAction = QAction(IconTool.buildQIcon('find.png'), '&Find', self)
        findAction.setShortcut('Ctrl+F')
        findAction.triggered.connect(self.findActionClick)
        editMenu.addAction(findAction)

        focusItemAction = QAction(IconTool.buildQIcon('focus.png'),
                                  '&Focus Item', self)
        focusItemAction.triggered.connect(self.focusChooseItem)
        editMenu.addAction(focusItemAction)
        self.chooseItemType = ''
        self.chooseItemId = ''

        settingMenu = menuBar.addMenu('Setting')
        autoLoginAction = QAction(IconTool.buildQIcon('setting.png'),
                                  '&Auto Login', self)
        autoLoginAction.setShortcutContext(Qt.ApplicationShortcut)
        autoLoginAction.triggered.connect(self.setAutoState)
        settingMenu.addAction(autoLoginAction)

        helpMenu = menuBar.addMenu('Help')
        aboutAction = QAction(IconTool.buildQIcon('about.png'), '&About', self)
        aboutAction.triggered.connect(self.openAboutWindow)
        helpMenu.addAction(aboutAction)
 def listUserObject():
     if XulDebugServerHelper.HOST == '':
         raise ValueError('Host is empty!')
     else:
         try:
             url = XulDebugServerHelper.HOST + XulDebugServerHelper.__LIST_USER_OBJECTS
             http = urllib3.PoolManager()
             r = http.request('GET', url)
         except Exception as e:
             STCLogger().e(e)
             return
         return r
 def getUserObject(objectId):
     if XulDebugServerHelper.HOST == '':
         raise ValueError('Host is empty!')
     else:
         try:
             url = XulDebugServerHelper.HOST + quote(
                 XulDebugServerHelper.__GET_USER_OBJECT + '/' + objectId)
             http = urllib3.PoolManager()
             r = http.request('GET', url)
         except Exception as e:
             STCLogger().e(e)
             return
         return r
Esempio n. 13
0
    def treeViewDataRefresh(self):
        dateTime = time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(time.time()))

        #用左侧的model树来查询的时候
        if isinstance(self.data, dict):
            FavoriteDB.insertHistory(self.providerName,self.url,dateTime,0)
            STCLogger().i('dataQuery record is insert to DataBase of history: ' + self.url)
            return

        #用收藏功能里面的记录查询
        if self.data.type:
            if self.data.type == 'favorites_type':#更新收藏记录的时候要先更新历史记录,在更新收藏记录时将最新的历史记录和收藏记录关联起来

                FavoriteDB.insertHistory(self.providerName, self.url,dateTime, 1)
                STCLogger().i('dataQuery record is insert to DataBase of history :' + self.url)
                rows = FavoriteDB.selectBySQL('select max(id) from '+ FavoriteDB.TABLE_HISTORY)
                for row in rows:
                    historyMaxId = row[0]
                FavoriteDB.updateFavorites('and id = '+ str(self.data.id), name = self.providerName,url = self.url,date = dateTime,history_id = historyMaxId)
                FavoriteDB.updateHistory('and id = '+str(self.data.historyId), favorite = 0)
                STCLogger().i('dataQuery record is update DataBase of favorites :' + self.url)
            elif self.data.type == 'history_type':
                FavoriteDB.insertHistory(self.providerName, self.url,dateTime, 0)
                STCLogger().i('dataQuery record is insert to DataBase of history :' + self.url)
 def getLayout(pageId,
               skipProp=True,
               withBindingData=True,
               withPosition=True,
               withSelector=True):
     if XulDebugServerHelper.HOST == '':
         raise ValueError('Host is empty!')
     else:
         try:
             url = XulDebugServerHelper.HOST + quote(
                 XulDebugServerHelper.__GET_LAYOUT + '/' + pageId)
             http = urllib3.PoolManager()
             r = http.request('GET',
                              url,
                              fields={
                                  'skip-prop': skipProp,
                                  'with-binding-data': withBindingData,
                                  'with-position': withPosition,
                                  'with-selector': withSelector
                              })
         except Exception as e:
             STCLogger().e(e)
             return
         return r
Esempio n. 15
0
 def showQueryDialog(self, data):
     STCLogger().i('show query dialog: ', data)
     self.dialog = DataQueryDialog(data)
     self.dialog.finishSignal.connect(self.onGetQueryUrl)
     self.dialog.show()
 def remove2Favorites(self, item):
     if item.type == ITEM_TYPE_FAVORITES:
         FavoriteDB.deleteFavorites('and id = ' + str(item.id))
         STCLogger().i('this record remove from DataBase of favorites:' +
                       item.url)
         self.updateTree()
 def deleteHistoryBatch(self, list):
     FavoriteDB.deleteHistoryBatch(list)
     STCLogger().i('A batch of historical records was deleted')
     self.updateTree()
 def deleteHistory(self, item):
     if item.type == ITEM_TYPE_HISTORY:
         FavoriteDB.deleteHistory('and id = ' + str(item.id))
         STCLogger().i('this record delete from DataBase:' + item.url)
         self.updateTree()
 def deleteFavoritesBatch(self, list):
     FavoriteDB.deleteFavoritesBatch(list)
     STCLogger().i('A batch of favorite records was deleted')
     self.updateTree()
Esempio n. 20
0
 def showXulDebugData(self, url):
     STCLogger().i('request url:' + url)
     self.browser.load(QUrl(url))
     self.statusBar().showMessage(url)
 def showQueryDialog(self, item):
     self.dialog = DataQueryDialog(item)
     self.dialog.finishSignal.connect(self.mainWindow.onGetQueryUrl)
     self.dialog.show()
     STCLogger().i('show queryDataDialog')
Esempio n. 22
0
# coding: utf-8
from XulDebugTool.logcatapi.Logcat import STCLogger
# 以下是日志模块基本类型调用接口
# 如果后期有跟多类型日志类型,将考虑更加具有扩展性的接口

STCLogger().i("这是一个info信息","你可以在后面加任意类型,任意数量的信息",{"1":"mke"},(1,2,3,4))

STCLogger().w("这是一个warning信息","你可以在后面加任意类型,任意数量的信息",{"1":"mke","rytu":"chaili"},(1,2,3,4))

STCLogger().e("这是一个error信息","你可以在后面加任意类型,任意数量的信息")

STCLogger().c("这是一个critical信息","你可以在后面加任意类型,任意数量的信息")

STCLogger().d("这是一个debug信息","你可以在后面加任意类型,任意数量的信息")

Esempio n. 23
0
 def onGetQueryUrl(self, url):
     STCLogger().i('request url:' + url)
     self.favoriteTreeView.updateTree()
     self.browser.load(QUrl(url))
     self.statusBar().showMessage(url)