summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Glüpker <git@wgmd.de>2016-04-08 10:17:10 +0200
committerAndré Glüpker <git@wgmd.de>2016-04-08 10:17:10 +0200
commit280d5a4222de687374486bf122e51c3bf9318f81 (patch)
treed2f76863e6e74f95d96726d595ec1d42389400fd
parent448016ddd7b450ee6b0a5f28798d076c16d540c0 (diff)
download9kwpyqt-280d5a4222de687374486bf122e51c3bf9318f81.tar.gz
9kwpyqt-280d5a4222de687374486bf122e51c3bf9318f81.tar.bz2
9kwpyqt-280d5a4222de687374486bf122e51c3bf9318f81.zip
New config option: Autostart
-rwxr-xr-x9kwpyqt.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/9kwpyqt.py b/9kwpyqt.py
index cbc84be..aceff68 100755
--- a/9kwpyqt.py
+++ b/9kwpyqt.py
@@ -180,8 +180,10 @@ class CaptchaGUI(QWidget):
def removeCaptchaImage(self):
self.captchaImage.removeImage()
- def toggleRunning(self):
- self.running = not self.running
+ def toggleRunning(self, force_start=False, force_stop=False):
+ if force_start: self.running = True
+ elif force_stop: self.running = False
+ else: self.running = not self.running
self.captchaImage.setText("")
self.offlinemessage = "Click \"Start\" to fetch next captcha."
self.startstopButton.setText(self.running and "Stop" or "Start")
@@ -325,11 +327,14 @@ class CaptchaGUI(QWidget):
# Handle logic
##################################################
def readConfig(self):
+ if self.config is not None:
+ return False
defaultconfig = {}
defaultconfig['API_URL'] = 'http://www.9kw.eu/index.cgi'
defaultconfig['API_KEY'] = ''
defaultconfig['Sound'] = 'yes'
defaultconfig['Soundfile'] = 'notify.wav'
+ defaultconfig['Autostart'] = 'no'
self.config = configparser.ConfigParser(defaultconfig)
try:
self.config.read_file(open('9kwpyqt.ini'))
@@ -344,6 +349,8 @@ class CaptchaGUI(QWidget):
self.apiurl = self.config['DEFAULT']['API_URL']+"?source=pythonapi&apikey="+self.config['DEFAULT']['API_KEY']+"&"
self.sound = QSound(self.config['DEFAULT']['Soundfile'])
self.soundCheckbox.setChecked( self.config.getboolean('DEFAULT', 'Sound') )
+ if self.config.getboolean('DEFAULT', 'Autostart'):
+ self.toggleRunning(force_start=True)
return True
def writeConfig(self):
@@ -371,11 +378,9 @@ class CaptchaGUI(QWidget):
timing = self.timeleft - time.time()
self.captchaTimer.setText(str(round(timing, 1))+"s")
if timing <= 0:
- self.timeleft = None
- self.running = False
+ self.toggleRunning(force_stop=True)
self.offlinemessage = "30 seconds passed without input."
- self.startstopButton.setText(self.running and "Stop" or "Start")
- self.startstopButton.setChecked(self.running)
+ self.timeleft = None
self.skipCaptcha()
def onQuit(self):