Simplify voting code
Not sure if I keep this feature, but at least I can now see if anybody is still using it...
This commit is contained in:
parent
ac9d8db1e8
commit
e24c0ae557
5 changed files with 8 additions and 19 deletions
|
@ -203,17 +203,8 @@ def vote_comic(scraperobj):
|
||||||
out.context = scraperobj.name
|
out.context = scraperobj.name
|
||||||
try:
|
try:
|
||||||
name = scraperobj.name
|
name = scraperobj.name
|
||||||
answer = scraperobj.vote()
|
scraperobj.vote()
|
||||||
out.debug(u'Vote answer %r' % answer)
|
out.info(u'Vote submitted.')
|
||||||
if answer == 'counted':
|
|
||||||
url = configuration.Url + 'comics/%s.html' % name.replace('/', '_')
|
|
||||||
out.info(u'Vote submitted. Votes are updated regularly at %s.' % url)
|
|
||||||
elif answer == 'no':
|
|
||||||
out.info(u'Vote not submitted - your vote has already been submitted before.')
|
|
||||||
elif answer == 'noname':
|
|
||||||
out.warn(u'The comic %s cannot be voted.' % name)
|
|
||||||
else:
|
|
||||||
out.warn(u'Error submitting vote parameters: %r' % answer)
|
|
||||||
except Exception as msg:
|
except Exception as msg:
|
||||||
out.exception(msg)
|
out.exception(msg)
|
||||||
errors += 1
|
errors += 1
|
||||||
|
|
|
@ -13,7 +13,7 @@ App = AppName + u' ' + __version__
|
||||||
|
|
||||||
Maintainer = u'Tobias Gruetzmacher'
|
Maintainer = u'Tobias Gruetzmacher'
|
||||||
MaintainerEmail = u'tobias-dosage@23.gs'
|
MaintainerEmail = u'tobias-dosage@23.gs'
|
||||||
Url = u'http://dosage.rocks/'
|
Url = u'https://dosage.rocks/'
|
||||||
SupportUrl = u'https://github.com/webcomics/dosage/issues'
|
SupportUrl = u'https://github.com/webcomics/dosage/issues'
|
||||||
UserAgent = u"Mozilla/5.0 (compatible; %s/%s; +%s)" % (AppName, __version__,
|
UserAgent = u"Mozilla/5.0 (compatible; %s/%s; +%s)" % (AppName, __version__,
|
||||||
Url)
|
Url)
|
||||||
|
@ -25,4 +25,4 @@ Freeware = AppName + u""" comes with ABSOLUTELY NO WARRANTY!
|
||||||
This is free software, and you are welcome to redistribute it
|
This is free software, and you are welcome to redistribute it
|
||||||
under certain conditions. Look at the file `COPYING' within this
|
under certain conditions. Look at the file `COPYING' within this
|
||||||
distribution."""
|
distribution."""
|
||||||
VoteUrl = "http://gaecounter.appspot.com/"
|
VoteUrl = "https://buildbox.23.gs/count/"
|
||||||
|
|
|
@ -259,11 +259,10 @@ class Scraper(object):
|
||||||
|
|
||||||
def vote(self):
|
def vote(self):
|
||||||
"""Cast a public vote for this comic."""
|
"""Cast a public vote for this comic."""
|
||||||
url = configuration.VoteUrl + 'count/'
|
|
||||||
uid = get_system_uid()
|
uid = get_system_uid()
|
||||||
data = {"name": self.name.replace('/', '_'), "uid": uid}
|
data = {"name": self.name.replace('/', '_'), "uid": uid}
|
||||||
page = urlopen(url, self.session, data=data)
|
response = self.session.post(configuration.VoteUrl, data=data)
|
||||||
return page.text
|
response.raise_for_status()
|
||||||
|
|
||||||
def get_download_dir(self, basepath):
|
def get_download_dir(self, basepath):
|
||||||
"""Try to find the corect download directory, ignoring case
|
"""Try to find the corect download directory, ignoring case
|
||||||
|
|
|
@ -54,4 +54,4 @@ def zenpencils():
|
||||||
add(GET, re.compile(r'https://cdn-zenpencils\.netdna-ssl\.com/wp-content/uploads/.*\.jpg'), _img(), content_type='image/jpeg')
|
add(GET, re.compile(r'https://cdn-zenpencils\.netdna-ssl\.com/wp-content/uploads/.*\.jpg'), _img(), content_type='image/jpeg')
|
||||||
|
|
||||||
def vote():
|
def vote():
|
||||||
add(POST, 'http://gaecounter.appspot.com/count/', 'no')
|
add(POST, 'https://buildbox.23.gs/count/', '')
|
||||||
|
|
|
@ -20,5 +20,4 @@ class TestVote(object):
|
||||||
@responses.activate
|
@responses.activate
|
||||||
def test_vote(self):
|
def test_vote(self):
|
||||||
httpmocks.vote()
|
httpmocks.vote()
|
||||||
answer = ATestScraper('Test_Test').vote()
|
ATestScraper('Test_Test').vote()
|
||||||
assert answer in ('counted', 'no'), 'invalid answer %r' % answer
|
|
||||||
|
|
Loading…
Reference in a new issue