Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
fce14013
Commit
fce14013
authored
16 years ago
by
Christophe Simonis
Browse files
Options
Downloads
Patches
Plain Diff
bug fix in mail sending
bzr revid: chs@tinyerp.com-892d3a57d27c905952d8b0a4cca0ae2b6027a9a9
parent
408e1072
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/tools/misc.py
+48
-4
48 additions, 4 deletions
bin/tools/misc.py
with
48 additions
and
4 deletions
bin/tools/misc.py
+
48
−
4
View file @
fce14013
...
...
@@ -207,6 +207,42 @@ def file_open(name, mode="r", subdir='addons'):
raise
IOError
,
'
File not found :
'
+
str
(
name
)
#----------------------------------------------------------
# iterables
#----------------------------------------------------------
def
flatten
(
list
):
"""
Flatten a list of elements into a uniqu list
Author: Christophe Simonis (christophe@tinyerp.com)
Examples:
>>>
flatten
([
'
a
'
])
[
'
a
'
]
>>>
flatten
(
'
b
'
)
[
'
b
'
]
>>>
flatten
(
[]
)
[]
>>>
flatten
(
[[],
[[]]]
)
[]
>>>
flatten
(
[[[
'
a
'
,
'
b
'
],
'
c
'
],
'
d
'
,
[
'
e
'
,
[],
'
f
'
]]
)
[
'
a
'
,
'
b
'
,
'
c
'
,
'
d
'
,
'
e
'
,
'
f
'
]
>>>
t
=
(
1
,
2
,(
3
,),
[
4
,
5
,
[
6
,
[
7
],
(
8
,
9
),
([
10
,
11
,
(
12
,
13
)]),
[
14
,
[],
(
15
,)],
[]]])
>>>
flatten
(
t
)
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
]
"""
def
isiterable
(
x
):
return
hasattr
(
x
,
"
__iter__
"
)
r
=
[]
for
e
in
list
:
if
isiterable
(
e
):
map
(
r
.
append
,
flatten
(
e
))
else
:
r
.
append
(
e
)
return
r
#----------------------------------------------------------
# Emails
#----------------------------------------------------------
...
...
@@ -241,11 +277,11 @@ def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=Non
s
.
connect
(
config
[
'
smtp_server
'
])
if
config
[
'
smtp_user
'
]
or
config
[
'
smtp_password
'
]:
s
.
login
(
config
[
'
smtp_user
'
],
config
[
'
smtp_password
'
])
s
.
sendmail
(
email_from
,
email_to
+
email_cc
+
email_bcc
,
msg
.
as_string
())
s
.
sendmail
(
email_from
,
flatten
([
email_to
,
email_cc
,
email_bcc
])
,
msg
.
as_string
())
s
.
quit
()
except
Exception
,
e
:
import
logging
logging
.
getLogger
().
info
(
str
(
e
))
logging
.
getLogger
().
error
(
str
(
e
))
return
True
...
...
@@ -295,11 +331,11 @@ def email_send_attach(email_from, email_to, subject, body, email_cc=None, email_
s
.
connect
(
config
[
'
smtp_server
'
])
if
config
[
'
smtp_user
'
]
or
config
[
'
smtp_password
'
]:
s
.
login
(
config
[
'
smtp_user
'
],
config
[
'
smtp_password
'
])
s
.
sendmail
(
email_from
,
email_to
+
email_cc
+
email_bcc
,
msg
.
as_string
())
s
.
sendmail
(
email_from
,
flatten
([
email_to
,
email_cc
,
email_bcc
])
,
msg
.
as_string
())
s
.
quit
()
except
Exception
,
e
:
import
logging
logging
.
getLogger
().
info
(
str
(
e
))
logging
.
getLogger
().
error
(
str
(
e
))
return
True
#----------------------------------------------------------
...
...
@@ -550,4 +586,12 @@ def mod10r(number):
report
=
codec
[
(
int
(
digit
)
+
report
)
%
10
]
return
result
+
str
((
10
-
report
)
%
10
)
if
__name__
==
'
__main__
'
:
import
doctest
doctest
.
testmod
()
# vim:noexpandtab
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment