created new sub-package loops.agent
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1777 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
f913b0d063
commit
8616289e2c
16 changed files with 448 additions and 0 deletions
45
agent/README.txt
Normal file
45
agent/README.txt
Normal file
|
@ -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)
|
4
agent/__init__.py
Normal file
4
agent/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
"""
|
||||
$Id$
|
||||
"""
|
||||
|
41
agent/agent.py
Normal file
41
agent/agent.py
Normal file
|
@ -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()
|
||||
|
34
agent/config.py
Normal file
34
agent/config.py
Normal file
|
@ -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
|
4
agent/crawl/__init__.py
Normal file
4
agent/crawl/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
"""
|
||||
$Id$
|
||||
"""
|
||||
|
26
agent/crawl/filesystem.py
Normal file
26
agent/crawl/filesystem.py
Normal file
|
@ -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
|
||||
|
128
agent/interfaces.py
Normal file
128
agent/interfaces.py
Normal file
|
@ -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.
|
||||
"""
|
27
agent/log.py
Normal file
27
agent/log.py
Normal file
|
@ -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
|
||||
|
14
agent/loops.tac
Normal file
14
agent/loops.tac
Normal file
|
@ -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)
|
||||
|
26
agent/schedule.py
Normal file
26
agent/schedule.py
Normal file
|
@ -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
|
||||
|
23
agent/tests.py
Executable file
23
agent/tests.py
Executable file
|
@ -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')
|
4
agent/transport/__init__.py
Normal file
4
agent/transport/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
"""
|
||||
$Id$
|
||||
"""
|
||||
|
26
agent/transport/httpput.py
Normal file
26
agent/transport/httpput.py
Normal file
|
@ -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
|
||||
|
4
agent/ui/__init__.py
Normal file
4
agent/ui/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
"""
|
||||
$Id$
|
||||
"""
|
||||
|
10
agent/ui/agent.html
Normal file
10
agent/ui/agent.html
Normal file
|
@ -0,0 +1,10 @@
|
|||
<html xmlns:nevow="http://nevow.com/ns/nevow/0.1">
|
||||
<head>
|
||||
<title>loops Agent</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>loops Agent</h1>
|
||||
|
||||
</body>
|
||||
</html>
|
32
agent/ui/web.py
Normal file
32
agent/ui/web.py
Normal file
|
@ -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')
|
||||
|
Loading…
Add table
Reference in a new issue