Skip to content

Commit

Permalink
Weitere Änderungen für Python2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
chriszero committed Sep 1, 2013
1 parent 53083f4 commit 7a09485
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tvsp2xmltv/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/python3
#!/usr/bin/python
# -*- coding: utf-8 -*-
16 changes: 8 additions & 8 deletions tvsp2xmltv/pictureLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import glob
from io import open
from os import path, remove, fchmod
import urllib
from urlparse import urlsplit
from . import defaults
from . import logger
from xml.etree.ElementTree import Element
Expand Down Expand Up @@ -32,9 +32,9 @@ def get_xml(self):
i = 0
for im in sorted(self.programme.gallery_hi.values()):
i += 1
file = self.__download_image(im, defaults.epgimages_dir)
if file:
icon = Element('icon', {'src': file})
f = self.__download_image(im, defaults.epgimages_dir)
if f:
icon = Element('icon', {'src': f})
icons.append(icon)
if i == defaults.number_of_images_per_show:
break
Expand All @@ -43,7 +43,7 @@ def get_xml(self):

def __download_image(self, file_url, file_dir):
suffix_list = ['jpg', 'gif', 'png']
file_name = urllib.parse.split(file_url)[2].split('/')[-1]
file_name = urlsplit(file_url)[2].split('/')[-1]
file_suffix = file_name.split('.')[1]
full_file_path = path.abspath(path.join(file_dir, file_name))
#check if file exists before downloading it again
Expand All @@ -52,9 +52,9 @@ def __download_image(self, file_url, file_dir):
else:
i = requests.get(file_url)
if file_suffix in suffix_list and i.status_code == requests.codes.ok:
with open(full_file_path, 'wb') as file:
fchmod(file.fileno(), defaults.file_mode)
file.write(i.content)
with open(full_file_path, 'wb') as f:
fchmod(f.fileno(), defaults.file_mode)
f.write(i.content)
logger.log("new file downloaded: {0}".format(full_file_path), logger.DEBUG)
else:
return False
Expand Down

0 comments on commit 7a09485

Please sign in to comment.