make runnable on Linux (ignore win imports conditionally); avoid hard-coded path and port setting
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2105 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
		
							parent
							
								
									999c25bf0b
								
							
						
					
					
						commit
						eee4e198c0
					
				
					 3 changed files with 96 additions and 77 deletions
				
			
		| 
						 | 
					@ -1,15 +1,22 @@
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					Start with ``twistd -noy loops/agent/loops.tac``.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$Id$
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from twisted.application import internet, service
 | 
					from twisted.application import internet, service
 | 
				
			||||||
from nevow import appserver
 | 
					from nevow import appserver
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from loops.agent.core import Agent
 | 
					from loops.agent.core import Agent
 | 
				
			||||||
from loops.agent.ui.web import AgentHome
 | 
					from loops.agent.ui.web import AgentHome
 | 
				
			||||||
from loops.agent.config import conf
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					agent = Agent()
 | 
				
			||||||
 | 
					conf = agent.config
 | 
				
			||||||
port = conf.ui.web.port or 10095
 | 
					port = conf.ui.web.port or 10095
 | 
				
			||||||
 | 
					
 | 
				
			||||||
application = service.Application('LoopsAgent')
 | 
					application = service.Application('LoopsAgent')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
site = appserver.NevowSite(resource=AgentHome(Agent()))
 | 
					site = appserver.NevowSite(resource=AgentHome(agent))
 | 
				
			||||||
webServer = internet.TCPServer(port, site)
 | 
					webServer = internet.TCPServer(port, site)
 | 
				
			||||||
webServer.setServiceParent(application)
 | 
					webServer.setServiceParent(application)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,36 +3,36 @@
 | 
				
			||||||
  <div class="body">
 | 
					  <div class="body">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <div class="content even menu-1">
 | 
					      <div class="content even menu-1">
 | 
				
			||||||
        <a href="http://localhost:8080" class="">Startpage</a>
 | 
					        <a href="/" class="">Startpage</a>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <div class="content odd menu-2">Agent configuration</div>
 | 
					      <div class="content odd menu-2">Agent configuration</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <div class="content odd menu-3">
 | 
					      <div class="content odd menu-3">
 | 
				
			||||||
        <a href="http://localhost:8080/joboverview" class="">
 | 
					        <a href="/joboverview" class="">
 | 
				
			||||||
          job overview
 | 
					          job overview
 | 
				
			||||||
        </a>
 | 
					        </a>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <div class="content odd menu-3">
 | 
					      <div class="content odd menu-3">
 | 
				
			||||||
         <a href="http://localhost:8080/collectOutlookMails" class="">
 | 
					         <a href="/collectOutlookMails" class="">
 | 
				
			||||||
            add outlook crawl job
 | 
					            add outlook crawl job
 | 
				
			||||||
         </a>
 | 
					         </a>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <div class="content odd menu-3">
 | 
					      <div class="content odd menu-3">
 | 
				
			||||||
         <a href="http://localhost:8080/collectFilesystem" class="">
 | 
					         <a href="/collectFilesystem" class="">
 | 
				
			||||||
            add filesystem crawl job</a>
 | 
					            add filesystem crawl job</a>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <div class="content odd menu-3">
 | 
					      <div class="content odd menu-3">
 | 
				
			||||||
         <a href="http://localhost:8080/viewRessources" class="">
 | 
					         <a href="/viewRessources" class="">
 | 
				
			||||||
            view collected ressources
 | 
					            view collected ressources
 | 
				
			||||||
         </a>
 | 
					         </a>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <div class="content odd menu-3">
 | 
					      <div class="content odd menu-3">
 | 
				
			||||||
         <a href="http://localhost:8080/loggingoptions" class="" title="">
 | 
					         <a href="/loggingoptions" class="" title="">
 | 
				
			||||||
            logging options
 | 
					            logging options
 | 
				
			||||||
         </a>
 | 
					         </a>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,6 +5,11 @@
 | 
				
			||||||
# version: 0.1
 | 
					# version: 0.1
 | 
				
			||||||
#------------------------------------------------------
 | 
					#------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$Id$
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import tempfile
 | 
					import tempfile
 | 
				
			||||||
| 
						 | 
					@ -12,14 +17,19 @@ import cPickle
 | 
				
			||||||
import traceback
 | 
					import traceback
 | 
				
			||||||
import time
 | 
					import time
 | 
				
			||||||
import email
 | 
					import email
 | 
				
			||||||
 | 
					try:
 | 
				
			||||||
    import _winreg as winreg
 | 
					    import _winreg as winreg
 | 
				
			||||||
 | 
					    USE_WINDOWS = True
 | 
				
			||||||
 | 
					except ImportError:
 | 
				
			||||||
 | 
					    USE_WINDOWS = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from nevow import loaders, rend, static, url, inevow, tags
 | 
					from nevow import loaders, rend, static, url, inevow, tags
 | 
				
			||||||
from nevow.inevow import IRequest
 | 
					from nevow.inevow import IRequest
 | 
				
			||||||
from twisted.internet import defer
 | 
					from twisted.internet import defer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from loops.agent.crawl import outlook
 | 
					 | 
				
			||||||
from loops.agent import core
 | 
					from loops.agent import core
 | 
				
			||||||
 | 
					if USE_WINDOWS:
 | 
				
			||||||
 | 
					    from loops.agent.crawl import outlook
 | 
				
			||||||
    from loops.agent.crawl.outlook import OutlookResource
 | 
					    from loops.agent.crawl.outlook import OutlookResource
 | 
				
			||||||
from loops.agent.crawl.filesystem import FileResource
 | 
					from loops.agent.crawl.filesystem import FileResource
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,7 +51,8 @@ _OUTLOOK_EXPRESS_ = "Office10"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def template(fn):
 | 
					def template(fn):
 | 
				
			||||||
    return loaders.xmlfile(os.path.join(templatesDirectory, fn))
 | 
					    return loaders.xmlfile(os.path.join(
 | 
				
			||||||
 | 
					                os.path.dirname(__file__), templatesDirectory, fn))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def getConfigIndex(agentobj, index_name, default_value, fn=None):
 | 
					def getConfigIndex(agentobj, index_name, default_value, fn=None):
 | 
				
			||||||
| 
						 | 
					@ -124,7 +135,8 @@ class AgentHome(rend.Page):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    child_resources = static.File(resourcesDirectory)
 | 
					    child_resources = static.File(os.path.join(
 | 
				
			||||||
 | 
					                        os.path.dirname(__file__),resourcesDirectory))
 | 
				
			||||||
    docFactory = template('agent.html')
 | 
					    docFactory = template('agent.html')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, agent=None, first_start=1):
 | 
					    def __init__(self, agent=None, first_start=1):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue