コード例 #1
0
ファイル: hostlist.py プロジェクト: ffeenn/Myterminal
 def Host_item_list(self):
     self.HostListWindow.tableWidget.clear()
     hosts = db().upda("select * from ssh_host")
     host_g = db().upda("select * from ssh_group")
     self.HostListWindow.tableWidget.setRowCount(len(host_g[0] + hosts[0]))
     for _id, item in enumerate(host_g[0] + hosts[0]):
         if len(item) == 2:
             items = HostItemWidget(item[1], self.Dir_Pixmap, '分组', item)
         else:
             items = HostItemWidget(item[1], self.Re_Pixmap, item[2], item)
             items.Send_edit.connect(self.Updata_host)
             # items.Left_QPush.clicked.connect(lambda:self.Add_host(True,True,item))
             # items.Left_QPush.clicked.connect(lambda:)
         items.Send_env.connect(self.Items_host)
         self.HostListWindow.tableWidget.setCellWidget(_id, 0, items)
コード例 #2
0
ファイル: hostlist.py プロジェクト: ffeenn/Myterminal
 def Items_host(self, ItemsList):
     self.HostList.tableWidget.clear()
     if len(ItemsList) == 2:
         host = db().upda("select * from ssh_host where hgroup='%s'" %
                          ItemsList[1])
         # if host[0]and len(ItemsList[0])==2:
         self.HostList.tableWidget.setRowCount(host[1])
         for _id, item in enumerate(host[0]):
             items = HostItemWidget(item[1], self.Re_Pixmap, item[2], item)
             items.Send_edit.connect(self.Updata_host)
             # items.Left_QPush.clicked.connect(lambda:self.Add_host(True,True,item))
             items.Send_env.connect(self.return_hosts)
             self.HostList.tableWidget.setCellWidget(_id, 0, items)
     else:
         self.return_hosts(ItemsList)
         return
     self.HostListWindow_Out.setStartValue(
         QRect(0, 0, self.width(), self.height()))
     self.HostListWindow_Out.setEndValue(
         QRect(0 - self.width(), 0, self.width(), self.height()))
     self.HostList_Out.setStartValue(
         QtCore.QRect(self.width(), 0, self.width(), self.height()))
     self.HostList_Out.setEndValue(QRect(0, 0, self.width(), self.height()))
     self.HostListWindow_Out.start()
     self.HostList_Out.start()
コード例 #3
0
 def get_ip_address_and_port(self):
     from DB import db
     default_value = "localhost:%r" % self.default_port
     return db(self.ip_address_and_port_db, default_value)
コード例 #4
0
import pandas

from DB import db
from Preprocessing import preprocess

count = 0
db = db()

allTweets = db.getAll()

hashtagDatetimes = []
for tweet in allTweets:
    # Hashtags list
    terms_hash = [
        term for term in preprocess(tweet['text'].lower())
        if term.startswith('#')
    ]
    if '#kathygriffin' in terms_hash:
        hashtagDatetimes.append(tweet['created_at'])
    # if count == 60000:
    #     break
    count += 1
    print("\rLive number of processed tweets: " + str(count), end="")

print("\n")
print("length of occurence array : " + str(len(hashtagDatetimes)))

# a list of "1" to count the hashtags
ones = [1] * len(hashtagDatetimes)
# the index of the series
idx = pandas.DatetimeIndex(hashtagDatetimes)
コード例 #5
0
ファイル: hostlist.py プロジェクト: ffeenn/Myterminal
 def addhost(self):
     if not self.lineEdit.text() or not self.lineEdit_2.text(
     ) or not self.lineEdit_3.text():
         return
     if not re.match(
             r"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$",
             self.lineEdit_2.text()):
         print('IP地址格式不正确')
         return
     if self.sender().text() == '更新':
         self.pushButton.setText("添加")
         db().upda("update ssh_host set name='%s',host='%s',port='%s',user='******',passwd='%s',cer='%s',hgroup='%s',cmd='%s' where id='%s'"%\
                   (self.lineEdit.text(),self.lineEdit_2.text(),self.lineEdit_3.text(),self.lineEdit_4.text(),\
                    self.lineEdit_5.text(),self.lineEdit_6.text(),self.lineEdit_7.text(),self.lineEdit_8.text(),self.host_id))
     elif self.sender().text() == '删除':
         db().upda("delete from ssh_host where id='%s'" % self.host_id)
     else:
         # 判断是否有重复IP
         if db().upda("select * from ssh_host where name ='%s'" %
                      self.lineEdit.text())[0]:
             print('名称重复')
             return
         if db().upda("select * from ssh_host where host ='%s'" %
                      self.lineEdit_2.text())[0]:
             print('IP重复')
             return
         db().upda("insert into ssh_host values (null,'%s','%s','%s','%s','%s','%s','%s','%s') " % \
                   (self.lineEdit.text(),self.lineEdit_2.text(),self.lineEdit_3.text(),self.lineEdit_4.text(),\
                    self.lineEdit_5.text(),self.lineEdit_6.text(),self.lineEdit_7.text(),self.lineEdit_8.text()))
     if not db().upda(
             "select * from ssh_group where hgroup ='%s'" %
             self.lineEdit_7.text())[0] and self.lineEdit_7.text() != '':
         db().upda("insert into ssh_group values(null,'%s')" %
                   self.lineEdit_7.text())
     for item in db().upda("select * from ssh_group")[0]:
         if item:
             if not db().upda("select * from ssh_host where hgroup='%s'" %
                              item[1])[0]:
                 db().upda("delete from ssh_group where id='%s'" % item[0])
     self.Send_clos.emit()
     self.clear_text()
コード例 #6
0
 def configuration_names(cls):
     from DB import db
     return db("configuration.names",[])
コード例 #7
0
 def __getitem__(self,row):
     from DB import db
     if type(row) == slice: value = [x for x in self]
     else: value = db(self.db_key(row),self.default_value)
     return value
コード例 #8
0
ファイル: AppEntry.py プロジェクト: zealzel/stockSmart
        wx.App.__init__(self)
        
        frame=View.mainFrame.myFrame(None,-1,"Stock Wizard")
        ctrl = Controller(db, frame)
        frame.gridPanel.setStyle()
        frame.Show()
        frame.Raise()

if __name__ == '__main__':
    
    print "App Start"
    dbFile='stockDB.db'
    
    print path.realpath(dbFile)
    
    DB=db(dbFile)
    #DB=db("%s/%s" % (sys.path[0],dbFile))   
    
    
    for tbl in DB.tables:
        if tbl.shouldUpdate==False:continue
        try:
            tbl.update()
        except Exception as ex:
            print "error : %s" % (ex,)
    
    app = myApp(DB)
    app.MainLoop()
    
    DB.closeCursor()
    print "App End"