Browse Source

[PEP8] Misc

pull/21/head
Sandy Carter 11 years ago
committed by Sandy Carter
parent
commit
49975648a8
  1. 2
      auth_admin_passkey/model/res_users.py
  2. 3
      auth_from_http_basic/__init__.py
  3. 20
      base_external_dbsource/base_external_dbsource.py
  4. 2
      configuration_helper/config.py
  5. 18
      dbfilter_from_header/__openerp__.py
  6. 2
      server_environment_files/__init__.py
  7. 4
      web_context_tunnel/__openerp__.py

2
auth_admin_passkey/model/res_users.py

@ -35,7 +35,7 @@ class res_users(Model):
# Private Function section # Private Function section
def _get_translation(self, cr, lang, text): def _get_translation(self, cr, lang, text):
context = {'lang': lang}
context = {'lang': lang} # noqa: _() checks page for locals
return _(text) return _(text)
def _send_email_passkey(self, cr, user_id, user_agent_env): def _send_email_passkey(self, cr, user_id, user_agent_env):

3
auth_from_http_basic/__init__.py

@ -36,7 +36,8 @@ def init(self, params):
base_location=self.httprequest.url_root.rstrip('/'), base_location=self.httprequest.url_root.rstrip('/'),
HTTP_HOST=self.httprequest.environ['HTTP_HOST'], HTTP_HOST=self.httprequest.environ['HTTP_HOST'],
REMOTE_ADDR=self.httprequest.environ['REMOTE_ADDR'] REMOTE_ADDR=self.httprequest.environ['REMOTE_ADDR']
))
)
)
WebRequest.init = init WebRequest.init = init

20
base_external_dbsource/base_external_dbsource.py

@ -34,13 +34,15 @@ try:
try: try:
import pymssql import pymssql
CONNECTORS.append(('mssql', 'Microsoft SQL Server')) CONNECTORS.append(('mssql', 'Microsoft SQL Server'))
except:
assert pymssql
except ImportError, AssertionError:
_logger.info('MS SQL Server not available. Please install "pymssql"\ _logger.info('MS SQL Server not available. Please install "pymssql"\
python package.') python package.')
try: try:
import MySQLdb import MySQLdb
CONNECTORS.append(('mysql', 'MySQL')) CONNECTORS.append(('mysql', 'MySQL'))
except:
assert MySQLdb
except ImportError, AssertionError:
_logger.info('MySQL not available. Please install "mysqldb"\ _logger.info('MySQL not available. Please install "mysqldb"\
python package.') python package.')
except: except:
@ -90,15 +92,15 @@ Sample connection strings:
} }
def conn_open(self, cr, uid, id1): def conn_open(self, cr, uid, id1):
#Get dbsource record
# Get dbsource record
data = self.browse(cr, uid, id1) data = self.browse(cr, uid, id1)
#Build the full connection string
# Build the full connection string
connStr = data.conn_string connStr = data.conn_string
if data.password: if data.password:
if '%s' not in data.conn_string: if '%s' not in data.conn_string:
connStr += ';PWD=%s' connStr += ';PWD=%s'
connStr = connStr % data.password connStr = connStr % data.password
#Try to connect
# Try to connect
if data.connector == 'cx_Oracle': if data.connector == 'cx_Oracle':
os.environ['NLS_LANG'] = 'AMERICAN_AMERICA.UTF8' os.environ['NLS_LANG'] = 'AMERICAN_AMERICA.UTF8'
conn = cx_Oracle.connect(connStr) conn = cx_Oracle.connect(connStr)
@ -134,13 +136,13 @@ Sample connection strings:
for obj in data: for obj in data:
conn = self.conn_open(cr, uid, obj.id) conn = self.conn_open(cr, uid, obj.id)
if obj.connector in ["sqlite", "mysql", "mssql"]: if obj.connector in ["sqlite", "mysql", "mssql"]:
#using sqlalchemy
# using sqlalchemy
cur = conn.execute(sqlquery, sqlparams) cur = conn.execute(sqlquery, sqlparams)
if metadata: if metadata:
cols = cur.keys() cols = cur.keys()
rows = [r for r in cur] rows = [r for r in cur]
else: else:
#using other db connectors
# using other db connectors
cur = conn.cursor() cur = conn.cursor()
cur.execute(sqlquery, sqlparams) cur.execute(sqlquery, sqlparams)
if metadata: if metadata:
@ -168,8 +170,6 @@ Sample connection strings:
except Exception: except Exception:
# ignored, just a consequence of the previous exception # ignored, just a consequence of the previous exception
pass pass
#TODO: if OK a (wizard) message box should be displayed
# TODO: if OK a (wizard) message box should be displayed
raise orm.except_orm(_("Connection test succeeded!"), raise orm.except_orm(_("Connection test succeeded!"),
_("Everything seems properly set up!")) _("Everything seems properly set up!"))
#EOF

2
configuration_helper/config.py

@ -40,7 +40,7 @@ class AbstractConfigSettings(orm.AbstractModel):
super(AbstractConfigSettings, self).__init__(pool, cr) super(AbstractConfigSettings, self).__init__(pool, cr)
if self._companyObject: if self._companyObject:
for field_key in self._companyObject._columns: for field_key in self._companyObject._columns:
#allows to exclude some field
# allows to exclude some field
if self._filter_field(field_key): if self._filter_field(field_key):
args = ('company_id', field_key) args = ('company_id', field_key)
kwargs = { kwargs = {

18
dbfilter_from_header/__openerp__.py

@ -19,14 +19,14 @@
# #
############################################################################## ##############################################################################
{ {
"name" : "dbfilter_from_header",
"version" : "1.0",
"author" : "Therp BV",
"name": "dbfilter_from_header",
"version": "1.0",
"author": "Therp BV",
"complexity": "normal", "complexity": "normal",
"description": """ "description": """
This addon lets you pass a dbfilter as a HTTP header. This addon lets you pass a dbfilter as a HTTP header.
This is interesting for setups where database names can't be mapped to
This is interesting for setups where database names can't be mapped to
proxied host names. proxied host names.
In nginx, use In nginx, use
@ -34,11 +34,11 @@
The addon has to be loaded as server-wide module. The addon has to be loaded as server-wide module.
""", """,
"category" : "Tools",
"depends" : [
"category": "Tools",
"depends": [
'web', 'web',
], ],
"data" : [
"data": [
], ],
"js": [ "js": [
], ],
@ -46,7 +46,7 @@
], ],
"auto_install": False, "auto_install": False,
"installable": True, "installable": True,
"external_dependencies" : {
'python' : [],
"external_dependencies": {
'python': [],
}, },
} }

2
server_environment_files/__init__.py

@ -17,4 +17,4 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
##############################################################################
##############################################################################

4
web_context_tunnel/__openerp__.py

@ -3,7 +3,7 @@
'category': 'Hidden', 'category': 'Hidden',
'author': 'Akretion', 'author': 'Akretion',
'license': 'AGPL-3', 'license': 'AGPL-3',
'description':"""
'description': """
Web Context Tunnel. Web Context Tunnel.
=================== ===================
@ -15,7 +15,7 @@ arguments. This is annoying as modules often need to pass extra arguments
that are not present in the base on_change signatures. As soon as two modules that are not present in the base on_change signatures. As soon as two modules
try to alter this signature to add their extra arguments, they are incompatible try to alter this signature to add their extra arguments, they are incompatible
between them unless some extra glue module make them compatible again by between them unless some extra glue module make them compatible again by
taking all extra arguments into account. But this leads to a combinatorial
taking all extra arguments into account. But this leads to a combinatorial
explosion to make modules compatible again. explosion to make modules compatible again.
The solution The solution

Loading…
Cancel
Save