Skip to content

Commit 0690393

Browse files
committed
-
1 parent 67dcf61 commit 0690393

File tree

4 files changed

+63
-3
lines changed

4 files changed

+63
-3
lines changed

python_toolbox/cute_profile/cute_profile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def inner(function_, *args, **kwargs):
9898
globals(), locals()
9999
)
100100

101-
if misc_tools
101+
if misc_tools.is_legal_email_address(profile_handler)
102102

103103
Z Z Z Do shit depending on `profile_handler`. Allow filename, folder, email address, or index for printing (sort). In any case do everything on a thread.
104104

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright 2009-2013 Ram Rachum.
2+
# This program is distributed under the MIT license.
3+
4+
import threading
5+
6+
import envelopes
7+
8+
9+
class BaseProfileHandler(object):
10+
__metaclass__ = abc.ABCMeta
11+
12+
@abc.abstractmethod
13+
def __call__(self):
14+
pass
15+
16+
17+
18+
class AuxiliaryThreadProfileHandler(BaseProfileHandler):
19+
20+
thread = None
21+
22+
def __call__(self):
23+
self.thread = threading.Thread(target=self.thread_job)
24+
self.thread.start()
25+
26+
@abc.abstractmethod
27+
def thread_job(self):
28+
pass
29+
30+
31+
class EmailProfileHandler(BaseProfileHandler):
32+
def __init__(self, email_address, smtp_server, smtp_user, smtp_password,
33+
use_tls=True):
34+
35+
self.email_address = email_address
36+
37+
s
38+
39+
def thread_job(self):
40+
envelope = envelopes.Envelope(to_addr=self.email_address,
41+
subject='Profile data')
42+
43+
envelope.add_attachment('/Users/bilbo/Pictures/helicopter.jpg')
44+
45+
envelope.send('smtp.googlemail.com', login='from@example.com',
46+
password='password', tls=True)
47+
48+
('profile-%s-%s' % (cleaned_path,
49+
datetime_tools.get_now()),
50+
profile_data,
51+
'application/octet-stream'),
52+
53+
54+
55+
56+
57+
def get_profile_handler(profile_handler_string):
58+
59+
60+

python_toolbox/misc_tools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
_ascii_variable_pattern, is_legal_ascii_variable_name,
99
is_magic_variable_name, get_actual_type, is_number, identity_function,
1010
do_nothing, OwnNameDiscoveringDescriptor, find_clear_place_on_circle,
11-
general_sum, general_product
11+
general_sum, general_product, is_legal_email_address
1212
)
1313
from . import name_mangling

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def get_packages():
133133
setuptools.setup(
134134
name='python_toolbox',
135135
version='0.4.1',
136-
requires=['distribute'],
136+
requires=['distribute', 'envelopes'],
137137
test_suite='nose.collector',
138138
install_requires=['distribute'],
139139
tests_require=['nose>=1.0.0',

0 commit comments

Comments
 (0)