~oubiwann/ubuntu-accomplishments-system/946850-twisted-app

« back to all changes in this revision

Viewing changes to accomplishments/daemon/api.py

  • Committer: Duncan McGreggor
  • Date: 2012-03-20 00:30:38 UTC
  • Revision ID: duncan@dreamhost.com-20120320003038-2ailsg4w7brgasue
* Moved the subprocess protocol into util where it could be used by everyone
  easily.
* Updated the gpg util to use this process protocol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
import accomplishments
39
39
from accomplishments import exceptions
40
40
from accomplishments.daemon import dbusapi
41
 
from accomplishments.util import get_data_file
 
41
from accomplishments.util import get_data_file, SubprocessReturnCodeProtocol
42
42
 
43
43
 
44
44
MATRIX_USERNAME = "openiduser155707"
46
46
SCRIPT_DELAY = 900
47
47
 
48
48
 
49
 
class SubprocessReturnCodeProtocol(ProcessProtocol):
50
 
    """
51
 
    """
52
 
    def connectionMade(self):
53
 
        self.returnCodeDeferred = defer.Deferred()
54
 
 
55
 
    def processEnded(self, reason):
56
 
        self.returnCodeDeferred.callback(reason.value.exitCode)
57
 
 
58
 
    def outReceived(self, data):
59
 
        # XXX let's use logging here instead
60
 
        print data
61
 
 
62
 
    def errReceived(self, data):
63
 
        # XXX let's use logging here instead
64
 
        print data
65
 
 
66
 
 
67
49
# XXX the source code needs to be updated to use Twisted async calls better:
68
50
# grep the source code for any *.asyncapi.* references, and if they return
69
51
# deferreds, adjust them to use callbacks