Document_ftp: cleanup code for lint

bzr revid: p_christ@hol.gr-20100810122957-y0wqscm0xcfppbqd
This commit is contained in:
P. Christeas
2010-08-10 15:29:57 +03:00
parent f2f6ec0423
commit 559df13770
4 changed files with 20 additions and 26 deletions
+7 -10
View File
@@ -1,9 +1,8 @@
# -*- encoding: utf-8 -*-
import os
import time
from tarfile import filemode
import StringIO
import base64
import logging
import errno
@@ -12,12 +11,11 @@ import fnmatch
import pooler
import netsvc
import os
from service import security
from osv import osv
#from document.nodes import node_res_dir, node_res_obj
from document.nodes import get_node_context
import stat
def _get_month_name(month):
month=int(month)
@@ -165,7 +163,7 @@ class abstracted_fs(object):
return ret
except EnvironmentError:
raise
except Exception,e:
except Exception:
self._log.exception('Cannot create item %s at node %s', objname, repr(node))
raise OSError(1, 'Operation not permited.')
@@ -177,7 +175,7 @@ class abstracted_fs(object):
try:
res = node.open_data(cr, mode)
cr.commit()
except TypeError, e:
except TypeError:
raise IOError(errno.EINVAL, "No data")
return res
@@ -188,12 +186,11 @@ class abstracted_fs(object):
name. Unlike mkstemp it returns an object with a file-like
interface.
"""
raise NotImplementedError
raise NotImplementedError # TODO
text = not 'b' in mode
# for unique file , maintain version if duplicate file
if dir:
# TODO
cr = dir.cr
uid = dir.uid
pool = pooler.get_pool(node.context.dbname)
@@ -234,7 +231,7 @@ class abstracted_fs(object):
cdir = node.create_child_collection(cr, basename)
self._log.debug("Created child dir: %r", cdir)
cr.commit()
except Exception,e:
except Exception:
self._log.exception('Cannot create dir "%s" at node %s', basename, repr(node))
raise OSError(1, 'Operation not permited.')
@@ -405,7 +402,7 @@ class abstracted_fs(object):
cr.commit()
except EnvironmentError:
raise
except Exception, err:
except Exception:
self._log.exception('Cannot rename "%s" to "%s" at "%s"', src, datacr[2], datacr[1])
raise OSError(1,'Operation not permited.')
+5 -3
View File
@@ -124,6 +124,7 @@ import stat
from tarfile import filemode
try:
# TODO: remove, no Unix credentials
import pwd
import grp
except ImportError:
@@ -194,6 +195,7 @@ proto_cmds = {
# hack around format_exc function of traceback module to grant
# backward compatibility with python < 2.4
# TODO: remove, we're not 2.4 compatible anyway
if not hasattr(traceback, 'format_exc'):
try:
import cStringIO as StringIO
@@ -1438,7 +1440,7 @@ class FTPHandler(asynchat.async_chat):
"""
try:
asynchat.async_chat.__init__(self, conn=conn) # python2.5
except TypeError, e:
except TypeError:
asynchat.async_chat.__init__(self, sock=conn) # python2.6
self.server = server
self.remote_ip, self.remote_port = self.socket.getpeername()[:2]
@@ -1866,7 +1868,7 @@ class FTPHandler(asynchat.async_chat):
self.respond('%s %s.' % (str(ret_code), why))
raise FTPExceptionSent(why)
except Exception, e:
except Exception, err:
cmdname = function.__name__
try:
logerror(traceback.format_exc())
@@ -2003,7 +2005,7 @@ class FTPHandler(asynchat.async_chat):
assert len(octs) == 4
for x in octs:
assert 0 <= x <= 255
except (AssertionError, ValueError, OverflowError), err:
except (AssertionError, ValueError, OverflowError):
self.respond("501 Invalid EPRT format.")
else:
self._make_eport(ip, port)
+6 -5
View File
@@ -20,8 +20,9 @@
##############################################################################
from osv import osv, fields
from tools.translate import _
# from tools.translate import _
from document_ftp import ftpserver
class document_ftp_browse(osv.osv_memory):
_name = 'document.ftp.browse'
_description = 'Document FTP Browse'
@@ -35,8 +36,8 @@ class document_ftp_browse(osv.osv_memory):
if 'url' in fields:
user_pool = self.pool.get('res.users')
current_user = user_pool.browse(cr, uid, uid, context=context)
dir_pool = self.pool.get('document.directory')
data_pool = self.pool.get('ir.model.data')
# dir_pool = self.pool.get('document.directory')
data_pool = self.pool.get('ir.model.data')
aid = data_pool._get_id(cr, uid, 'document_ftp', 'action_document_browse')
aid = data_pool.browse(cr, uid, aid, context=context).res_id
ftp_url = self.pool.get('ir.actions.url').browse(cr, uid, aid, context=context)
@@ -50,12 +51,12 @@ class document_ftp_browse(osv.osv_memory):
def browse_ftp(self, cr, uid, ids, context):
data_id = ids and ids[0] or False
data = self.browse(cr, uid, data_id, context)
data = self.browse(cr, uid, data_id, context)
final_url = data.url
return {
'type': 'ir.actions.act_url',
'url':final_url,
'target': 'new'
}
document_ftp_browse()
@@ -19,14 +19,8 @@
#
##############################################################################
import base64
from osv import osv, fields
from osv.orm import except_orm
from tools import config
import urlparse
import os
class document_ftp_configuration(osv.osv_memory):
@@ -46,10 +40,10 @@ class document_ftp_configuration(osv.osv_memory):
def execute(self, cr, uid, ids, context=None):
conf = self.browse(cr, uid, ids[0], context)
dir_pool = self.pool.get('document.directory')
data_pool = self.pool.get('ir.model.data')
data_pool = self.pool.get('ir.model.data')
# Update the action for FTP browse.
aid = data_pool._get_id(cr, uid, 'document_ftp', 'action_document_browse')
aid = data_pool.browse(cr, uid, aid, context=context).res_id
self.pool.get('ir.actions.url').write(cr, uid, [aid], {'url': 'ftp://'+(conf.host or 'localhost:8021')+'/'})
document_ftp_configuration()