Skip to content

Commit

Permalink
- Fixed date exception. Caused the app not to start working.
Browse files Browse the repository at this point in the history
- Fixed regex match for getting the right amount of internet usage.
Thanks to Maurits
  • Loading branch information
theyosh committed Dec 6, 2015
1 parent 912c429 commit fe61e61
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.ChoozzeScraper.data.bin
.ChoozzeScraper.history.bin
ChoozzeStatus.pro.user
ChoozzeStatus.pro.user*
.DS_Store
qml/python/__pycache__/
Binary file added builds/ChoozzeStatus-0.6-2.armv7hl.rpm
Binary file not shown.
2 changes: 1 addition & 1 deletion qml/ChoozzeStatus.qml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ ApplicationWindow

property bool dataLoading: false
property bool __debug: false
property string version: '0.6.1'
property string version: '0.6.2'

id: choozzeMainApp
initialPage: Component { Home {} }
Expand Down
2 changes: 1 addition & 1 deletion qml/pages/Settings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Dialog {
id: updateTimeout
width: parent.width
inputMethodHints: Qt.ImhNoPredictiveText
label: qsTr('Update timeout')
label: qsTr('Update timeout in hours')
placeholderText: qsTr('Enter the timeout in hours for updating')
text: choozzeMainApp.choozzeData.data_update_timeout
validator: IntValidator { bottom: 2; top: 24 }
Expand Down
15 changes: 10 additions & 5 deletions qml/python/ChoozzeScraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import time
import json
import threading
from datetime import date, datetime
from datetime import date, datetime, timedelta

import Encryption

Expand Down Expand Up @@ -60,9 +60,9 @@ def __init__(self, username = None ,password = None):
self.regex_phonenumber = re.compile('<p>.*nummer:\s(?P<phonenumber>\+\d{11})\s*<\/p>')
self.regex_mobile_plan = re.compile('<p>.*gekozen voor\s*(?P<mobileplan>[^</]+)<\/p>')
self.regex_extra_costs = re.compile('<p>Buitenbundelkosten:\s(?P<currentcy>.*)(?P<extra_costs>\d+,\d+)\s*<\/p>')
self.regex_sms_usage = re.compile('(?P<totalsms>\d+) SMSjes voor \S+ \((?P<usedsms>\d+)%[^</]+')
self.regex_call_usage = re.compile('(?P<totalcall>\d+) belminuten voor \S+ \((?P<usedcall>\d+)%[^</]+')
self.regex_data_usage = re.compile('(?P<totaldata>\d+)(?P<dataunit>[(M|G)B]+) mobiel internet \S+ \((?P<useddata>\d+)%[^</]+')
self.regex_sms_usage = re.compile('(?P<totalsms>\d+) SMSjes[^)]+ \((?P<usedsms>\d+)%')
self.regex_call_usage = re.compile('(?P<totalcall>\d+) belminuten[^)]+ \((?P<usedcall>\d+)%')
self.regex_data_usage = re.compile('(?P<totaldata>\d+)(?P<dataunit>[(M|G)B]+) mobiel internet[^)]+\((?P<useddata>\d+)%')
self.internetdata_unit = 1000

# Voicemail regexes
Expand Down Expand Up @@ -221,6 +221,11 @@ def __parse_data(self,type,html):
if 'callforward' == type:
self.__parse_callforward_data(html)

# Credits: http://stackoverflow.com/questions/42950/get-last-day-of-the-month-in-python#13565185
def __days_in_month(self,any_day):
next_month = any_day.replace(day=28) + timedelta(days=4) # this will never fail
return int((next_month - timedelta(days=next_month.day)).day)

def __parse_account_data(self,html):
self.application_data['mobile_number'] = self.regex_phonenumber.search(html).group('phonenumber')
self.application_data['mobile_plan'] = self.regex_mobile_plan.search(html).group('mobileplan')
Expand Down Expand Up @@ -260,7 +265,7 @@ def __parse_account_data(self,html):
self.application_data['data_usage']['free'] = int(self.application_data['data_usage']['total']) - int(self.application_data['data_usage']['used'])

now = date.today()
self.application_data['days_usage']['total'] = (date(now.year, now.month+1, 1) - date(now.year, now.month, 1)).days
self.application_data['days_usage']['total'] = self.__days_in_month(now)
self.application_data['days_usage']['used'] = now.day
self.application_data['days_usage']['free'] = int(self.application_data['days_usage']['total']) - int(self.application_data['days_usage']['used'])

Expand Down
2 changes: 1 addition & 1 deletion qml/python/MockData.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def getpage(page):
<h1>Welkom Choozzer!</h1>
<p>Jouw Choozze nummer: +31600000009 </p>
<p>
<p>Jij hebt gekozen voor Choozze Zero</p><b>Happiness verbruiksmeter</b><br/><div class="row"><div class="col-xs-12 col-md-8">100 SMSjes voor nop (13% gebruikt)</div><div class="col-xs-6 col-md-4"></div></div><div class="row"><div class="col-xs-12 col-md-8">100 belminuten voor nop (5% gebruikt)</div><div class="col-xs-6 col-md-4"></div></div><div class="row"><div class="col-xs-12 col-md-8">500MB mobiel internet NL (3% gebruikt)</div><div class="col-xs-6 col-md-4"><a class="btn btn-aanpassen btn-xs" href="https://choozze.me/changedata.php?addon=500MB">Bundel wijzigen</a></div></div><div class="row"><div class="col-xs-12 col-md-8">Geen Onderling bundel</div><div class="col-xs-6 col-md-4"><a class="btn btn-aanpassen btn-xs" href="https://choozze.me/changevoice.php?addon=geen">Bundel wijzigen</a></div></div><br/><div class="row"><div class="col-xs-12 col-md-8"><b>Europa</b><br/><i>Met de Europa bundel kan je kiezen uit 100MB, 200M of 400MB</i></div><div class="col-xs-6 col-md-4"><a class="btn btn-reserveren btn-sm" href="https://choozze.me/changeroaming.php?addon=roam100">Reserveer hier je Europa bundel</a></div></div></p><p>Buitenbundelkosten: &euro;0,00</p>
<p>Jij hebt gekozen voor Choozze Zero</p><b>Happiness verbruiksmeter</b><br/><div class="row"><div class="col-xs-12 col-md-8">100 SMSjes voor nop (13% gebruikt)</div><div class="col-xs-6 col-md-4"></div></div><div class="row"><div class="col-xs-12 col-md-8">100 belminuten voor nop (5% gebruikt)</div><div class="col-xs-6 col-md-4"></div></div><div class="row"><div class="col-xs-12 col-md-8">100MB mobiel internet NL (3% gebruikt)</div><div class="col-xs-6 col-md-4"><a class="btn btn-aanpassen btn-xs" href="https://choozze.me/changedata.php?addon=500MB">Bundel wijzigen</a></div></div><div class="row"><div class="col-xs-12 col-md-8">Geen Onderling bundel</div><div class="col-xs-6 col-md-4"><a class="btn btn-aanpassen btn-xs" href="https://choozze.me/changevoice.php?addon=geen">Bundel wijzigen</a></div></div><br/><div class="row"><div class="col-xs-12 col-md-8"><b>Europa</b><br/><i>Met de Europa bundel kan je kiezen uit 100MB, 200M of 400MB</i></div><div class="col-xs-6 col-md-4"><a class="btn btn-reserveren btn-sm" href="https://choozze.me/changeroaming.php?addon=roam100">Reserveer hier je Europa bundel</a></div></div></p><p>Buitenbundelkosten: &euro;0,00</p>
Buitenbundelkosten kunnen onder andere bevatten: Overschrijdingen van de aanwezige bundels,
kosten voor bellen naar servicenummers, kosten voor bellen naar het buitenland of roaming kosten
(indien geen Europa bundel actief is, of er buiten de EU is gereisd).
Expand Down
4 changes: 4 additions & 0 deletions rpm/ChoozzeStatus.changes
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
# * date Author's Name <author's email> version-release
# - Summary of changes

* Sun Dec 6 2015 TheYOSH <OpenRepos@theyosh.nl> 0.6.2
- Fixed date exception. Caused the app not to start working.
- Fixed regex match for getting the right amount of internet usage. Thanks to Maurits

* Sun Nov 22 2015 TheYOSH <OpenRepos@theyosh.nl> 0.6.1
- Removed not needed imports
- Resized the loader icon
Expand Down
2 changes: 1 addition & 1 deletion rpm/ChoozzeStatus.spec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Name: ChoozzeStatus
%{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: Choozze Account Status
Version: 0.6
Release: 1
Release: 2
Group: Qt/Qt
License: LICENSE
URL: https://theyosh.nl/
Expand Down
2 changes: 1 addition & 1 deletion rpm/ChoozzeStatus.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Name: ChoozzeStatus
Summary: Choozze Account Status
Version: 0.6
Release: 1
Release: 2
# The contents of the Group field should be one of the groups listed here:
# http://gitorious.org/meego-developer-tools/spectacle/blobs/master/data/GROUPS
Group: Qt/Qt
Expand Down
6 changes: 3 additions & 3 deletions translations/ChoozzeStatus-nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,15 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Update timeout</source>
<source>Enter the timeout in hours for updating</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter the timeout in hours for updating</source>
<source>Reset settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset settings</source>
<source>Update timeout in hours</source>
<translation type="unfinished"></translation>
</message>
</context>
Expand Down
6 changes: 3 additions & 3 deletions translations/ChoozzeStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,15 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Update timeout</source>
<source>Enter the timeout in hours for updating</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enter the timeout in hours for updating</source>
<source>Reset settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Reset settings</source>
<source>Update timeout in hours</source>
<translation type="unfinished"></translation>
</message>
</context>
Expand Down

0 comments on commit fe61e61

Please sign in to comment.