commit 4b02a217d4f43182b1634615bfc935dc213034c1 Author: Arturo Filastò hellais@gmail.com Date: Sun Mar 4 15:13:54 2012 -0800
Start implementing the work unit classes * Fix ascii art --- logo.py | 32 ++++++++++++++++---------------- plugoo.py | 46 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 59 insertions(+), 19 deletions(-)
diff --git a/logo.py b/logo.py index 5669eae..3b47775 100644 --- a/logo.py +++ b/logo.py @@ -141,16 +141,16 @@ o O o O O o O o O O o O o O O """) logo.append(""" ________________________________________ -/ OONI-PROBE -- WE FIGHT CENSORSHIP LIKE \ +/ OONI-PROBE -- WE FIGHT CENSORSHIP LIKE \ \ DRAGONS EAT KNIGHTS! / ---------------------------------------- \ ^ /^ - \ / \ // \ - \ |___/| / // .\ + \ / \ // \ + \ |___/| / // .\ \ /O O __ / // | \ \ *----* / / /_/ // | \ \ \ | - @___@` /_ // | \ \ /\ \ - 0/0/| /_ // | \ \ \ \ + @___@` /_ // | \ \ /\ \ + 0/0/| /_ // | \ \ \ \ 0/0/0/0/| /// | \ \ | | 0/0/0/0/0/_|_ / ( // | \ _\ | / 0/0/0/0/0/0/`/,_ _ _/ ) ; -. | _ _.-~ / / @@ -158,8 +158,8 @@ o O o O O o O o O O o O o O O \ __/ `/\ / ~-. _ .-~ / ____(oo) *. } { / ( (--) .----~-.\ -` .~ - //__\ __ Ack! ///.----..< \ _ -~ - // \ ///-._ _ _ _ _ _ _{^ - - - - ~ + //__\\ __ Ack! ///.----..< \ _ -~ + // \\ ///-._ _ _ _ _ _ _{^ - - - - ~ """) logo.append(""" _________________ @@ -167,17 +167,17 @@ o O o O O o O o O O o O o O O | DON'T CENSOR ME | |_________________| \ . . - \ / `. .' " + \ / `. .' " \ .---. < > < > .---. \ | \ \ - ~ ~ - / / | _____ ..-~ ~-..-~ | (A)| ~~~.' `./~~~/ --------- __/ __/ - .' O \ / / \ " + .' O \ / / \ " (_____, `._.' | } /~~~/ `----. / } | / __/ `-. | / | / `. ,~~| - ~-.__| /_ - ~ ^| /- _ `..-' + ~-.__| /_ - ~ ^| /- _ `..-' | / | / ~-. `-. _ _ _ |_____| |_____| ~ - . _ _ _ _ _> """) @@ -189,16 +189,16 @@ o O o O O o O o O O o O o O O `_-_/` | ...DOES THIS | ~~~ | EXCITE YOU? | __| |__ |_________________| - | | + | | | af | | | | | - | | | \ - | | |\ \ - | | | \ \ - | | | \ \ + | | | \ + | | |\ \ + | | | \ \ + | | | \ \ | |___| ((( (((|/*| - | | | + | | | | | | | | | | | | diff --git a/plugoo.py b/plugoo.py index 0ce1d28..07f553d 100644 --- a/plugoo.py +++ b/plugoo.py @@ -26,7 +26,8 @@ import itertools import gevent
class Asset: - """This is an ooni-probe asset. It is a python + """ + This is an ooni-probe asset. It is a python iterator object, allowing it to be efficiently looped. To create your own custom asset your should subclass this and override the next_asset method and the len method for @@ -106,7 +107,7 @@ class Report: import paramiko except: self.scp = None - self.logger.warn("Could not import paramiko. SCP will not be disabled") + self.logger.warn("Could not import paramiko. SCP will be disabled")
def __call__(self, data): """ @@ -231,6 +232,44 @@ class Report: self.logger.info("Reporting to %s" % type) getattr(self, type+"_report").__call__(data)
+class Worker(): + """ + The worker is responsible for keeping track + of WorkUnits. Generating them, reading them. + This allows for resume support and dispatching + work units to remote OONI control centers. + """ + def __init__(self, status=None): + self.status = 0 + if status: + self.resumeStatus(status) + + def resumeStatus(self, status): + pass + + def next(self): + pass + +class WorkUnits(): + """ + This is a unit of work. It is associated with a node on + which it should be performed and a set of tasks to fulfil. + """ + def __init__(self): + pass + + def __iter__(self): + return self + + def next(self): + try: + return self + except: + raise StopIteration + + + + class Plugoo(): def __init__(self, ooni): self.config = ooni.config @@ -323,7 +362,8 @@ class Plugoo(): jobs = []
class torify(object): - """This is the torify decorator. It should be used to + """ + This is the torify decorator. It should be used to decorate functions that should use to for connecting to the interwebz. The suggary syntax is the following: @torify([urllib2])
tor-commits@lists.torproject.org