Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
dmlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
domotika
dmlib
Commits
72132f93
Commit
72132f93
authored
Feb 15, 2014
by
nextime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved ConvenienceCaller here
parent
c810fe2d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
0 deletions
+41
-0
genutils.py
dmlib/utils/genutils.py
+29
-0
webutils.py
dmlib/utils/webutils.py
+12
-0
No files found.
dmlib/utils/genutils.py
View file @
72132f93
...
@@ -31,8 +31,37 @@ except:
...
@@ -31,8 +31,37 @@ except:
import
md5
import
md5
import
sha1
import
sha1
class
ConvenienceCaller
(
object
):
"""
This metaclass build and abstraction of an object instance so
that other objects can call it as it is a module, and permit
to the original object to setup a specific callback
to the caller so it can manage the calls originated by the caller
with local methods
"""
def
__init__
(
self
,
callerfunc
):
"""
@params callerfunc: function/method to be used as callback
inside the original class of the abstract object
"""
self
.
callerfunc
=
callerfunc
def
__getattribute__
(
self
,
name
):
"""
This do the magic, transforming every called method in a call
to the callerfunction of the original object
This method isn't intended to be called directly!
"""
callerfunc
=
object
.
__getattribute__
(
self
,
'callerfunc'
)
return
callerfunc
(
name
)
from
ConfigParser
import
SafeConfigParser
from
ConfigParser
import
SafeConfigParser
def
revlist
(
l
):
l
.
reverse
();
return
l
def
revlist
(
l
):
l
.
reverse
();
return
l
class
FakeObject
(
object
):
class
FakeObject
(
object
):
...
...
dmlib/utils/webutils.py
View file @
72132f93
...
@@ -132,6 +132,17 @@ class HTTPPageGetter(client.HTTPPageGetter):
...
@@ -132,6 +132,17 @@ class HTTPPageGetter(client.HTTPPageGetter):
self
.
transport
.
loseConnection
()
self
.
transport
.
loseConnection
()
def
handleStatus_401
(
self
):
self
.
handleStatusDefault
()
self
.
factory
.
noPage
(
failure
.
Failure
(
error
.
Error
(
self
.
status
,
self
.
message
,
None
)
)
)
self
.
quietLoss
=
0
self
.
transport
.
loseConnection
()
def
handleStatus_301
(
self
):
def
handleStatus_301
(
self
):
l
=
self
.
headers
.
get
(
'location'
)
l
=
self
.
headers
.
get
(
'location'
)
if
not
l
:
if
not
l
:
...
@@ -250,6 +261,7 @@ class HTTPClientFactory(client.HTTPClientFactory):
...
@@ -250,6 +261,7 @@ class HTTPClientFactory(client.HTTPClientFactory):
res
=
(
page
,
self
.
uniqueid
)
res
=
(
page
,
self
.
uniqueid
)
self
.
deferred
.
callback
(
res
)
self
.
deferred
.
callback
(
res
)
def
gotHeaders
(
self
,
headers
):
def
gotHeaders
(
self
,
headers
):
if
self
.
headerscb
and
callable
(
self
.
headerscb
):
if
self
.
headerscb
and
callable
(
self
.
headerscb
):
self
.
headerscb
(
headers
)
self
.
headerscb
(
headers
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment