Exemple #1
0
 def addRecord(self):
     row = self.model.rowCount()
     self.model.insertRow(row)
     
     now = QDateTime.currentDateTime()
     self.dateTimeEdit.setDateTime(now)
     self.sppLineEdit.setFocus()
     self.mapper.setCurrentIndex(row)
Exemple #2
0
    def updateTotal(self):
        stat = self.model.total
        total = BandwidthTableModel.smart_bytes(stat['total'])
        received = BandwidthTableModel.smart_bytes(stat['received'])
        transmitted = BandwidthTableModel.smart_bytes(stat['transmitted'])
        self.labelTotal.setText(total)
        self.labelTotalReceived.setText(received)
        self.labelTotalTransmitted.setText(transmitted)
        self.labelUptime.setText(BandwidthTableModel.formatUptime(stat['uptime']))

        tps = BandwidthTableModel.smart_bytes(self.model.tps)
        rps = BandwidthTableModel.smart_bytes(self.model.rps)
        self.labelRps.setText("%s/s" % rps)
        self.labelTps.setText("%s/s" % tps)
        now = QLocale().toString(QDateTime.currentDateTime(), u'dd MMMM, yyyy hh:mm:ss')
        self.labelTime.setText(now)
Exemple #3
0
    def __init__(self):
        QtCore.QObject.__init__(self)
        # Manager hat alle collections
        self.defaultManager = QOrganizerManager()
        self.collections = self.defaultManager.collections()
        # Kontrolle
        print len(self.collections)

        # Infos über collections mit metaData(), für alle Meta-Daten einfach nur metaData() aufrufen
        for collection in self.collections:
            print collection.metaData()
            print collection.metaData('Color'), collection.metaData('Name')

        # Filter erzeugen und mit ausgewählten Collections bestücken, hier über Namen
        self.collectionFilter = QOrganizerItemCollectionFilter()
        for collection in self.collections:
            if collection.metaData()['Name'] == u'Nokia N900':
                self.collectionFilter.setCollectionId(collection.id())
  
        now = QDateTime.currentDateTime()
        days_ahead = 150
        # ohne Filter liefert alle collection-einträge
        #self.items = self.defaultManager.items(now,now.addDays(days_ahead))

        # mit Filter nur die aus dem N900 Kalender
        self.items = self.defaultManager.items(now,now.addDays(days_ahead),self.collectionFilter)

        # Items je nach Typ umwandeln und Eigenschaften ausgeben lassen
        for item in self.items:
            if item.type() == 'Todo':
                todo = QOrganizerTodo(item)
                print (todo.dueDateTime().toString("dd.MM.yyyy hh:mm:ss"),
                       todo.displayLabel()) 
            if item.type() == 'EventOccurrence':
                occurrence = QOrganizerEventOccurrence(item)
                print (occurrence.startDateTime().toString("dd.MM.yyyy hh:mm:ss"),
                       occurrence.endDateTime().toString("dd.MM.yyyy hh:mm:ss"), 
                       occurrence.displayLabel(), 
                       occurrence.location()) 
            if item.type() == 'Event':
                event = QOrganizerEvent(item)
                print (event.startDateTime().toString("dd.MM.yyyy hh:mm:ss"), 
                       event.endDateTime().toString("dd.MM.yyyy hh:mm:ss"),
                       event.displayLabel(),
                       event.location(),
                       event.id())
        sys.exit(0)
Exemple #4
0
    def __init__(self, playersOut, playersIn, parent=None):
        super(confirmSubsDialog, self).__init__(parent)
        
        self.now = QDateTime.currentDateTime()
        self.now.setTime(QTime(self.now.time().hour(), self.now.time().minute()))
        
        self.setWindowTitle("Confirm Subs")
        mainVerticalLayout = QVBoxLayout(self)
        
        subsLayout = QGridLayout()
        mainVerticalLayout.addLayout(subsLayout)
        
        subsLayout.addWidget(QLabel("<b>Players Out</b>"), 0, 0)
        subsLayout.addWidget(QLabel("<b>Players In</b>"), 0, 1)

        for i, (playerOut, playerIn) in enumerate(zip(playersOut, playersIn)):
            playerOutLabel = QLabel()
            playerOutLabel.setText("<font color=red>{0}</font>".format(playerOut.name))
            subsLayout.addWidget(playerOutLabel, i+1, 0)
            
            playerInLabel = QLabel()
            playerInLabel.setText("<font color=green>{0}</font>".format(playerIn.name))
            subsLayout.addWidget(playerInLabel, i+1, 1)
            
        mainVerticalLayout.addItem(QSpacerItem(0, 15, QSizePolicy.Minimum, QSizePolicy.Expanding))
        
        dateTimeLayout = QHBoxLayout()
        mainVerticalLayout.addLayout(dateTimeLayout)
        dateTimeLayout.addWidget(QLabel("Date and time"))
        
        self.dateTimeEdit = QDateTimeEdit(self.now)
        self.dateTimeEdit.setMaximumDateTime(self.now)
        self.dateTimeEdit.setCalendarPopup(True)
        self.dateTimeEdit.setDisplayFormat("d MMM yy h:mm AP")
        
        dateTimeLayout.addWidget(self.dateTimeEdit)
        dateTimeLayout.addStretch()
        
        mainVerticalLayout.addItem(QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding))
        
        buttonBox = QDialogButtonBox(self)
        buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok)
        buttonBox.button(QDialogButtonBox.Ok).setText("&Accept")
        mainVerticalLayout.addWidget(buttonBox)

        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
Exemple #5
0
    def testInsert(self):
        myHash = {}
        qdate = QDate.currentDate()
        qdatetime = QDateTime.currentDateTime()
        qtime = QTime.currentTime()
        qurl = QUrl("http://www.pyside.org")
        qpoint = QPoint(12, 42)

        myHash[qdate] = "QDate"
        myHash[qdatetime] = "QDateTime"
        myHash[qtime] = "QTime"
        myHash[qurl] = "QUrl"
        myHash[qpoint] = "QPoint"

        self.assertEqual(myHash[qdate], "QDate")
        self.assertEqual(myHash[qdatetime], "QDateTime")
        self.assertEqual(myHash[qtime], "QTime")
        self.assertEqual(myHash[qurl], "QUrl")
        self.assertEqual(myHash[qpoint], "QPoint")
 def updtTime(self):
     """ Function to update current time
     """
     currentTime = QDateTime.currentDateTime().toString('hh:mm:ss')
     self.myTimeDisplay.display(currentTime)
Exemple #7
0
 def update(self):
     url = "http://bugs.pyside.org/buglist.cgi?bug_status=UNCONFIRMED&bug_status=NEW&bug_status=WAITING&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=RESOLVED&bug_status=VERIFIED&product=PySide&query_format=advanced&resolution=---&resolution=FIXED&ctype=csv"
     self._timeStamp = QDateTime.currentDateTime().toString("h:mm ap")
     self.manager.get(QNetworkRequest(QUrl(url)))
Exemple #8
0
 def on_timeout(self):
     now = QDateTime.currentDateTime()
     self.dateTimeEdit.setDateTime(now)
Exemple #9
0
 def updtTime(self):
     currentTime=QDateTime.currentDateTime().toString("hh:mm:ss")
     self.myTimeDisplay.display(currentTime)
    def updtTime(self):
        """ Function to update current time
		"""
        currentTime = QDateTime.currentDateTime().toString('hh:mm:ss')
        self.myTimeDisplay.display(currentTime)
Exemple #11
0
 def testSetTimestampFunction(self):
     dt = QDateTime.currentDateTime()
     posinfo = QGeoPositionInfo()
     posinfo.setTimestamp(dt)
     self.assertEqual(dt, posinfo.timestamp())
Exemple #12
0
 def updtTime(self):
     currentTime = QDateTime.currentDateTime().toString("hh:mm:ss")
     self.myTimeDisplay.display(currentTime)
    def handleOddsHtmlPage(self, htmlPage, source=BETEXPLORER_SOURCE):
        print "handleOddsHtmlPage source = %d" % source
        epochDate = self._gridList[self._index][1]
        date = QDateTime()
        date.setMSecsSinceEpoch(int(epochDate) * 1000)
        deprecated = QDateTime.currentDateTime() > date.addDays(+1)

        strHtml = str(htmlPage)
        if source == BETEXPLORER_SOURCE:
            oddsRx = QRegExp(
                "<a href=.*data-odd-max=\"(\\d*\.\\d*)\".*data-odd-max=\"(\\d*\.\\d*)\".*data-odd-max=\"(\\d*\.\\d*)\".*>")
        elif source == ZULUBET_SOURCE:
            oddsRx = QRegExp(
                "<td\\s*class=\"aver_odds_full\"\\s*align=\"center\">(\\d*\.\\d*)</td><td\\s*class=\"aver_odds_full\"\\s*align=\"center\">(\\d*\.\\d*)</td><td\\s*class=\"aver_odds_full\"\\s*align=\"center\">(\\d*\.\\d*)</td>")

        for match in self._grid.matches():
            if not match.cotesDisponibles():
                if source == BETEXPLORER_SOURCE and not deprecated:
                    team1Rx = QRegExp(
                        "><span>(\\w*[\\'\\.-]?\\s*)*(%s)(\\w*[\\'\\.-]?\\s*)*</span>\\s*-\\s*<span>\\s*((\\w*[\\'\\.-]?\\s*)*)</span><" % match.team1())
                    team1Rx.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
                    team2Rx = QRegExp(
                        "><span>\\s*(\\w*[\\'\\.-]?\\s*)*</span>\\s*-\\s*<span>(\\w*[\\'\\.-]?\\s*)*(%s)(\\w*[\\'\\.-]?\\s*)*</span><" % match.team2())
                    team2Rx.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
                elif source == ZULUBET_SOURCE:
                    team1Rx = QRegExp(
                        #"<img\\s*src=\"http://www\.zulubet\.com/flags/flag-\\w*\.png\"\\s*class=\"flags\\s*flag-\\w*\"\\s*title=\"(\\w*\\'?\\s*-?)*,(\\w*\\'?\\s*-?)*\"\\s*width=\"\\d*\"\\s*height=\"\\d*\">\\s*(%s)\\s*-\\s*(\\w*\\'?\\s*-?)*<\img>" % match.team1())
                        "width=\"\\d*\"\\s*height=\"\\d*\">\\s*(%s)\\s*-\\s*(\\w*[\\'\\.-]?\\s*)*</td>" % match.team1())
                    team1Rx.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
                    team2Rx = QRegExp(
                        "width=\"\\d*\"\\s*height=\"\\d*\">(\\w*[\\'\\.-]?\\s*)*-\\s*(%s)\\s*</td>" % match.team2())
                    team2Rx.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
                else:
                    team1Rx = QRegExp("---deprecated---")
                    team2Rx = QRegExp("---deprecated---")

                # team2Rx = QRegExp(match.team2())
                teamXRx = team1Rx
                posi = teamXRx.indexIn(strHtml)
                posi2 = team2Rx.indexIn(strHtml)
                #if posi < 0:
                    #print "-1-%s- not found" % match.team1()
                    #teamXRx = team2Rx
                    #posi = teamXRx.indexIn(strHtml)
                #if (posi >= 0) and (posi2 >= 0):
                if (posi >= 0) and (posi2 == posi):
                    print "-%s- found" % ''.join((match.team1(), " vs " + match.team2()))
                else:  # try in an other way
                    print "-%s- not found, try another way" % ''.join((match.team1(), " vs " + match.team2()))
                    # split team names
                    team1list = match.team1().split(" ")
                    team2list = match.team2().split(" ")
                    # find the longest
                    maxLen = 0
                    miniTeam1 = ""
                    for elt1 in team1list:
                        if len(elt1) > maxLen:
                            maxLen = len(elt1)
                            miniTeam1 = filter(onlyascii, elt1)
                    maxLen = 0
                    miniTeam2 = ""
                    for elt2 in team2list:
                        if len(elt2) > maxLen:
                            maxLen = len(elt2)
                            miniTeam2 = filter(onlyascii, elt2)
                    print "Try with {0} vs {1}".format(miniTeam1, miniTeam2)
                    if source == BETEXPLORER_SOURCE and not deprecated:
                        teamRx = QRegExp(
                            "><span>\\s*(\\w*\\'?\\s*-?)*{0}(\\w*\\'?\\s*-?)*</span>\\s*-\\s*<span>(\\w*\\'?\\s*-?)*{1}(\\w*\\'?\\s*-?)*</span><".format(
                                miniTeam1, miniTeam2))
                    elif source == ZULUBET_SOURCE:
                        #teamRx = QRegExp(
                            #"<img\\s*src=\"http://www\.zulubet\.com/flags/flag-\\w*\.png\"\\s*class=\"flags\\s*flag-\\w*\"\\s*title=\"(\\w*\\'?\\s*-?)*,(\\w*\\'?\\s*-?)*\"\\s*width=\"\\d*\"\\s*height=\"\\d*\">(\\w*\\'?\\s*-?)*{0}(\\w*\\'?\\s*-?)*-(\\w*\\'?\\s*-?)*{1}(\\w*\\'?\\s*-?)*<\img>".format(
                                #miniTeam1, miniTeam2))
                        teamRx = QRegExp("\">(\\w*\\'?\\s*-?)*{0}(\\w*\\'?\\s*-?)*-(\\w*\\'?\\s*-?)*{1}(\\w*\\'?\\s*-?)*</td>".format(miniTeam1, miniTeam2))
                    else:
                        teamRx = QRegExp("---deprecated---")
                        print "---GRID DEPRECATED---"

                    teamRx.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
                    posi = teamRx.indexIn(strHtml)
                    if posi >= 0:
                        print "found : {0} vs {1}".format(miniTeam1, miniTeam2)
                    else:
                        print "still not found :'("
                        # print "Odds handling KO %s not found" % str(match)
                if posi >= 0:
                    print "posi = %d" % posi
                    posi = oddsRx.indexIn(strHtml, posi)
                    oddStr1 = oddsRx.cap(1)
                    oddStr2 = oddsRx.cap(2)
                    oddStr3 = oddsRx.cap(3)
                    print "read odds1 = %s" % oddStr1
                    try:
                        match.setCotes(float(oddsRx.cap(1)), float(oddsRx.cap(2)), float(oddsRx.cap(3)))
                        team1 = filter(onlyascii, match.team1())
                        team2 = filter(onlyascii, match.team2())
                        print "Odds handling OK : %s" % team1 + " vs " + team2
                        print "Odds handling OK : "
                        match.setCotesDisponibles(True)
                    except:
                        team1 = filter(onlyascii, match.team1())
                        team2 = filter(onlyascii, match.team2())
                        print "Odds handling OK : cant read odds for %s" % team1 + " vs " + team2
        return
Exemple #14
0
        print query.lastError().text()

def populate_observations(data):

    query.prepare("INSERT INTO observations (SPECIES, ABBR, COUNT, TIME, "
                  "LOCATION, NOTES) VALUES (?, ?, ?, ?, ?, ?)")
    for species, abbr, count, time, location, notes in data:
        query.addBindValue(species)
        query.addBindValue(abbr)
        query.addBindValue(count) # QDateTime
        query.addBindValue(time)   # QDateTime
        query.addBindValue(location)
        query.addBindValue(notes) # int
        query.exec_()

DATETIME_FORMAT = "dd.MM.yyyy hh:mm"
data = [[10,
         10,
         5, 
         QDateTime.currentDateTime(),
         "Herttoniemi",
         "Hieno!"],
         [4,
          4,
          100,
          QDateTime.currentDateTime(),
          "62.12414 38.214124",
          "Ei niin hieno"]
         ]
create_observations()
populate_observations(data)
Exemple #15
0
    def fresh1(self):

        self.dateTimeEdit.setDateTime(QDateTime.currentDateTime())
        self.dateTimeEdit.setDisplayFormat("yyyy-MM-dd HH:mm:ss")