22
from twisted.internet import task
23
from twisted.internet.error import AlreadyCancelled
24
21
from zope.component import (
29
from zope.component.interfaces import ComponentLookupError
30
25
from zope.interface import implements
32
from canonical.launchpad.interfaces.gpghandler import IGPGHandler
33
27
from lp.poppy.filesystem import UploadFileSystem
34
28
from lp.poppy.hooks import Hooks
35
29
from lp.services.sshserver.events import SFTPClosed
55
49
self.hook.new_client_hook(self._current_upload, 0, 0)
56
50
self.hook.auth_verify_hook(self._current_upload, None, None)
58
self._gpghandler_job = None
59
# stop the GPGHandler job on normal termination.
60
atexit.register(self._stopGPGHandlerJob)
61
# start the GPGHandler job
62
self._scheduleGPGHandlerJob()
64
def _scheduleGPGHandlerJob(self, touch_interval=12 * 3600):
65
# Create a job to touch the GPGHandler home directory every so often
66
# so that it does not get cleaned up by any reaper scripts which look
67
# at time last modified..
69
self._stopGPGHandlerJob()
71
self._gpghandler_job = task.LoopingCall(
72
getUtility(IGPGHandler).touchConfigurationDirectory)
73
return self._gpghandler_job.start(touch_interval)
74
except ComponentLookupError:
75
# No GPGHandler so no need to start the job.
78
def _stopGPGHandlerJob(self):
80
if self._gpghandler_job and self._gpghandler_job.running:
81
self._gpghandler_job.stop()
82
except AlreadyCancelled:
83
# So we're already cancelled, meh.
86
52
def gotVersion(self, other_version, ext_data):