diff --git a/agent/README.txt b/agent/README.txt new file mode 100644 index 0000000..15c16fd --- /dev/null +++ b/agent/README.txt @@ -0,0 +1,45 @@ +=============================================================== +loops - Linked Objects for Organization and Processing Services +=============================================================== + +loops agents - running on client systems and other services, +collecting informations and transferring them to the loops server. + + ($Id$) + +This package does not depend on zope or the other loops packages +but represents a standalone application. + + +Basic Configuration +=================== + +Parameter(s): URL of target loops site. + +(Future extension: use more than one target loops site) + + +Local File System +================= + +Configuration +------------- + +Parameters: directories to search, schedules. + +Logging info +------------ + + +E-Mail-Clients +============== + + +Software Update +=============== + + +Fin de partie +============= + +(tearDown) diff --git a/agent/__init__.py b/agent/__init__.py new file mode 100644 index 0000000..4bc90fb --- /dev/null +++ b/agent/__init__.py @@ -0,0 +1,4 @@ +""" +$Id$ +""" + diff --git a/agent/agent.py b/agent/agent.py new file mode 100644 index 0000000..2e6b863 --- /dev/null +++ b/agent/agent.py @@ -0,0 +1,41 @@ +# +# Copyright (c) 2007 Helmut Merz helmutm@cy55.de +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +""" +The real agent stuff. + +$Id$ +""" + +from zope.interface import implements +from loops.agent.interfaces import IAgent +from loops.agent.config import Configurator + + +class Agent(object): + + implements(IAgent) + + def __init__(self): + configurator = self.configurator = Configurator() + configurator.loadConfiguration() + + +def startAgent(): + return Agent() + diff --git a/agent/config.py b/agent/config.py new file mode 100644 index 0000000..db79be2 --- /dev/null +++ b/agent/config.py @@ -0,0 +1,34 @@ +# +# Copyright (c) 2007 Helmut Merz helmutm@cy55.de +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +""" +Management of agent configuration. + +$Id$ +""" + +from zope.interface import implements +from loops.agent.interfaces import IConfigurator + + +class Configurator(object) + + implements(IConfigurator) + + def loadConfiguration(self): + pass diff --git a/agent/crawl/__init__.py b/agent/crawl/__init__.py new file mode 100644 index 0000000..4bc90fb --- /dev/null +++ b/agent/crawl/__init__.py @@ -0,0 +1,4 @@ +""" +$Id$ +""" + diff --git a/agent/crawl/filesystem.py b/agent/crawl/filesystem.py new file mode 100644 index 0000000..f82040b --- /dev/null +++ b/agent/crawl/filesystem.py @@ -0,0 +1,26 @@ +# +# Copyright (c) 2007 Helmut Merz helmutm@cy55.de +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +""" +Filesystem crawler. + +$Id$ +""" + +from loops.agent.interfaces import ICrawler + diff --git a/agent/interfaces.py b/agent/interfaces.py new file mode 100644 index 0000000..8b6f23a --- /dev/null +++ b/agent/interfaces.py @@ -0,0 +1,128 @@ +# +# Copyright (c) 2007 Helmut Merz helmutm@cy55.de +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +""" +loops client agent interfaces. + +$Id$ +""" + +from zope.interface import Interface, Attribute + + +class IAgent(Interface): + """ An agent watches its client, looks for resources to process, + and transfers these to its server. + """ + + +class IScheduler(Interface): + """ Manages jobs and cares that they are started at the appropriate + time. + """ + + logger = Attribute('Logger instance to be used for recording ' + 'job execution and execution results.') + + def schedule(job, startTime): + """ Register the job given for execution at the intended start + date/time. + """ + + def getJobsToExecute(startTime=None): + """ Return a collection of jobs that are scheduled for execution at + or before the date/time given. + + If startTime is None the current date/time is used. + """ + + +class IScheduledJob(Interface): + """ A job that will be executed on some external triggering at + a predefined date and time. + """ + + startTime = Attribute('Date/time at which the job should be executed.') + params = Attribute('Mapping with key/value pairs to be passed to the ' + 'execute method call as keyword parameters.') + + def execute(**kw): + """ Execute the job. + + Store log information about job execution in a log record. + """ + + def reschedule(startTime): + """ Re-schedule the job, setting the date/time the job should be + executed again. + """ + + +class ILogger(Interface): + """ Collection of log records. + """ + + +class ILogRecord(Interface): + """ + """ + + +class ICrawler(Interface): + """ Collects resources. + """ + + def collect(**criteria): + """ Return a collection of resources that should be transferred + the the server using the selection criteria given. + """ + + +class ITransporter(Interface): + """ Transfers collected resources to the server. A resource need + not be transferred immediately, resources may be be collected + first and transferred later together, e.g. as a compressed file. + """ + + serverURL = Attribute('URL of the server the resources will be ' + 'transferred to. The URL also determines the ' + 'transfer protocol, e.g. HTTP or FTP.') + method = Attribute('Transport method, e.g. PUT.') + + def transfer(resource, resourceType=file): + """ Transfer the resource (typically just a file that may + be read) to the server. + """ + + def commit(): + """ Transfer all resources not yet transferred. + """ + + +class IConfigurator(Interface): + """ Manages (stores and receives) configuration information. + """ + + def loadConfiguration(): + """ Find the configuration settings and load them. + """ + + def getConfigOption(key): + """ Return the value for the configuration option identified + by the key given. + """ diff --git a/agent/log.py b/agent/log.py new file mode 100644 index 0000000..1e3126e --- /dev/null +++ b/agent/log.py @@ -0,0 +1,27 @@ +# +# Copyright (c) 2007 Helmut Merz helmutm@cy55.de +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +""" +Log information management. + +$Id$ +""" + +from zope.interface import implements +from loops.agent.interfaces import ILogger, ILogRecord + diff --git a/agent/loops.tac b/agent/loops.tac new file mode 100644 index 0000000..f1fac4f --- /dev/null +++ b/agent/loops.tac @@ -0,0 +1,14 @@ +from twisted.application import internet, service +from nevow import appserver + +from loops.agent.agent import startAgent +from loops.agent.ui.web import AgentHome + +port = 10095 + +application = service.Application('LoopsAgent') + +site = appserver.NevowSite(resource=AgentHome(startAgent())) +webServer = internet.TCPServer(port, site) +webServer.setServiceParent(application) + diff --git a/agent/schedule.py b/agent/schedule.py new file mode 100644 index 0000000..2d7d6f4 --- /dev/null +++ b/agent/schedule.py @@ -0,0 +1,26 @@ +# +# Copyright (c) 2007 Helmut Merz helmutm@cy55.de +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +""" +Job scheduling. + +$Id$ +""" + +from loops.agent.interfaces import IScheduler, IScheduledJob + diff --git a/agent/tests.py b/agent/tests.py new file mode 100755 index 0000000..980c1f8 --- /dev/null +++ b/agent/tests.py @@ -0,0 +1,23 @@ +# $Id$ + +import unittest, doctest +from zope.testing.doctestunit import DocFileSuite +from zope.interface.verify import verifyClass +from loops.expert import query + +class Test(unittest.TestCase): + "Basic tests for the loops.agent package." + + def testSomething(self): + pass + + +def test_suite(): + flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS + return unittest.TestSuite(( + unittest.makeSuite(Test), + DocFileSuite('README.txt', optionflags=flags), + )) + +if __name__ == '__main__': + unittest.main(defaultTest='test_suite') diff --git a/agent/transport/__init__.py b/agent/transport/__init__.py new file mode 100644 index 0000000..4bc90fb --- /dev/null +++ b/agent/transport/__init__.py @@ -0,0 +1,4 @@ +""" +$Id$ +""" + diff --git a/agent/transport/httpput.py b/agent/transport/httpput.py new file mode 100644 index 0000000..684e353 --- /dev/null +++ b/agent/transport/httpput.py @@ -0,0 +1,26 @@ +# +# Copyright (c) 2007 Helmut Merz helmutm@cy55.de +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +""" +Transferring of data/files to the server. + +$Id$ +""" + +from loops.agent.interfaces import ITransporter + diff --git a/agent/ui/__init__.py b/agent/ui/__init__.py new file mode 100644 index 0000000..4bc90fb --- /dev/null +++ b/agent/ui/__init__.py @@ -0,0 +1,4 @@ +""" +$Id$ +""" + diff --git a/agent/ui/agent.html b/agent/ui/agent.html new file mode 100644 index 0000000..043c239 --- /dev/null +++ b/agent/ui/agent.html @@ -0,0 +1,10 @@ + + + loops Agent + + + +

loops Agent

+ + + diff --git a/agent/ui/web.py b/agent/ui/web.py new file mode 100644 index 0000000..9bdeeb0 --- /dev/null +++ b/agent/ui/web.py @@ -0,0 +1,32 @@ +# +# Copyright (c) 2007 Helmut Merz helmutm@cy55.de +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +""" +Web interfaces for the loops agent. + +$Id$ +""" + +from nevow import loaders, rend + + +class AgentHome(rend.Page): + + addSlash = True + docFactory = loaders.xmlfile('ui/agent.html') +