2 # -*- coding: utf-8 -*-
4 #Copyright 2008-2011 Carl Gherardi
5 #This program is free software: you can redistribute it and/or modify
6 #it under the terms of the GNU Affero General Public License as published by
7 #the Free Software Foundation, version 3 of the License.
9 #This program is distributed in the hope that it will be useful,
10 #but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 #GNU General Public License for more details.
14 #You should have received a copy of the GNU Affero General Public License
15 #along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #In the "official" distribution you can find the license in agpl-3.0.txt
18 """A script for fetching Winamax tourney results"""
20 _
= L10n
.get_translation()
25 import logging
, os
, sys
29 def fetch_winamax_results_page(tourney_id
):
30 url
= "https://www.winamax.fr/poker/tournament.php?ID=%s" % tourney_id
31 data
= urllib2
.urlopen(url
).read()
34 def write_file(filename
, data
):
35 f
= open(filename
, 'w')
42 config
= Configuration
.Config()
43 db
= Database
.Database(config
)
45 tourney_ids
= db
.getSiteTourneyNos("Winamax")
48 for tid
in tourney_ids
:
49 blah
, = tid
# Unpack tuple
50 tids
.append(str(blah
))
51 # winamax_get_winning(tid,"blah")
52 results_dir
= config
.get_import_parameters().get("ResultsDirectory")
53 results_dir
= os
.path
.expanduser(results_dir
)
54 site_dir
= os
.path
.join(results_dir
, "Winamax")
55 print "DEBUG: site_dir: %s" % site_dir
56 filelist
= [file for file in os
.listdir(site_dir
) if not file in [".",".."]]
57 print "DEBUG: filelist : %s" % filelist
58 print "DEBUG: tids : %s" % tids
64 print "Warning: '%s' is not a known tourney_id" % f
67 print "No tourney results files to fetch"
70 filename
= os
.path
.join(site_dir
, tid
)
71 data
= fetch_winamax_results_page(tid
)
72 print u
"DEBUG: write_file(%s)" %(filename)
73 write_file(filename
, data
)
75 if __name__
== '__main__':