Menu

#22 Python 2.4 Compatibility pull request(s)

v1.0 (example)
open
nanotube
5
2015-01-17
2014-07-09
Leonard
No

Hi nanotube!
There are 2 issues when compiling with python 2.4, because this version didnt accept an except-block together with a finally-block in one try-block and one with the defining of a class:
Last first:

1)
File; Line:
controlpanel.py; 214

<<<<<<<Before:>>>>>>

class ConfigPanel():

<<<<<<<After:>>>>>>>

class ConfigPanel:


2)
File; Line:
timerthreads.py; 126

<<<<<<<Before:>>>>>>

try:
self.logger.debug("Handler %r: rolling over" % handler)
handler.doRollover()
except AttributeError:
self.logger.debug("Handler %r is not capable of rollover." % \ handler)
finally:
self.dir_lock.release()

<<<<<<<After:>>>>>>>

try:
try:
self.logger.debug("Handler %r: rolling over" % handler)
handler.doRollover()
except AttributeError:
self.logger.debug("Handler %r is not capable of rollover." % \ handler)
finally:
self.dir_lock.release()


3)
File; Line:
timerthreads.py; 458

<<<<<<<Before:>>>>>>

try:
zipfile_list = os.listdir(self.log_full_dir)
# removing elements from a list while iterating over it produces
# undesirable results so we make a copy
zipfile_list_copy = copy.deepcopy(zipfile_list)
self.logger.debug(str(zipfile_list))
if len(zipfile_list) > 0:

    for filename in zipfile_list_copy:
        if not self.needs_ftping(filename):
            zipfile_list.remove(filename)
            self.logger.debug("removing %s from "
                "zipfilelist." % filename)

self.logger.debug(str(zipfile_list))

## now actually connect and upload
ftp = ftplib.FTP()
if self.cmdoptions.debug: 
    ftp.set_debuglevel(2)
ftp.connect(host=self.subsettings['FTP']['FTP Server'], 
            port=self.subsettings['FTP']['FTP Port'])
ftp.login(user = self.subsettings['FTP']['FTP Username'],
            passwd = myutils.password_recover(\
                self.subsettings['FTP']['FTP Password']))
ftp.set_pasv(self.subsettings['FTP']['FTP Passive Mode'])
## todo: make sure to create directory first??
ftp.cwd(self.subsettings['FTP']['FTP Upload Directory'])
for filename in zipfile_list:
    ftp.storbinary('STOR ' + filename, 
            open(os.path.join(self.log_full_dir, filename), 'rb'))
ftp.quit()

except:
self.logger.debug('Error in ftp upload.', exc_info=True)
finally:
self.dir_lock.release()

<<<<<<<After:>>>>>>>

try:
try:
zipfile_list = os.listdir(self.log_full_dir)
# removing elements from a list while iterating over it produces
# undesirable results so we make a copy
zipfile_list_copy = copy.deepcopy(zipfile_list)
self.logger.debug(str(zipfile_list))
if len(zipfile_list) > 0:

        for filename in zipfile_list_copy:
            if not self.needs_ftping(filename):
                zipfile_list.remove(filename)
                self.logger.debug("removing %s from "
                    "zipfilelist." % filename)

    self.logger.debug(str(zipfile_list))

    ## now actually connect and upload
    ftp = ftplib.FTP()
    if self.cmdoptions.debug: 
        ftp.set_debuglevel(2)
    ftp.connect(host=self.subsettings['FTP']['FTP Server'], 
                port=self.subsettings['FTP']['FTP Port'])
    ftp.login(user = self.subsettings['FTP']['FTP Username'],
                passwd = myutils.password_recover(\
                    self.subsettings['FTP']['FTP Password']))
    ftp.set_pasv(self.subsettings['FTP']['FTP Passive Mode'])
    ## todo: make sure to create directory first??
    ftp.cwd(self.subsettings['FTP']['FTP Upload Directory'])
    for filename in zipfile_list:
        ftp.storbinary('STOR ' + filename, 
                open(os.path.join(self.log_full_dir, filename), 'rb'))
    ftp.quit()
except:
    self.logger.debug('Error in ftp upload.', exc_info=True)

finally:
self.dir_lock.release()

I didnt find any GitHub-repo to do pull requests which would be much easier to merge ;)

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.