コード例 #1
0
ファイル: Get Item Fields.py プロジェクト: amancevice/legacy
import sys

# add packages from Java into the python module library
sys.add_package("org.python.core")
sys.add_package("com.vamosa.tasks")
sys.add_package("com.vamosa.utils")
sys.add_package("net.sitecore.vamosa")

from com.vamosa.tasks import ParameterisedTask
from com.vamosa.utils import DOM4JUtils
from com.vamosa.utils import Base64

from java.io import ByteArrayInputStream
from java.net import URL
from javax.xml.namespace import QName
from net.sitecore.vamosa import VamosaServiceLocator

class MyParameterisedClass(ParameterisedTask):
	def usage(self):
		self.requiresProject("project", "the default project")
		self.requiresString("itemPath","Path to item")
		self.requiresString("service","URL of Vamosa Web Service")
		self.requiresString("db","database name")

	def enhanceProject( self, project, itemPath, service, db ):
		sitecore = VamosaService()
		sitecore.init_service(service)
		if db == None: db = "master"
		
		logger.info(sitecore.getItemFields(itemPath,db))
		
コード例 #2
0
ファイル: Output.py プロジェクト: Alli1223/Comp120-moodboard
	def __init__(self, filename):
		self.zipfile = ZipOutputStream(FileOutputStream(filename))
		
	def getName(self, name):
		return string.join(string.split(name, '.'), '/')+'.class'

	def getFile(self, name):
		fname = self.getName(name)
		self.zipfile.putNextEntry(ZipEntry(fname))
		return self.zipfile
		
	def close(self):
		self.zipfile.close()

try:		
	sys.add_package('com.ms.util.cab')
	from com.ms.util import cab
	import com.ms.util.cab.CabCreator
	from java.util import Date
	
	class CabOutput(cab.CabProgressInterface):
		def progress(self, ptype, val1, val2, data):
			pass
			#print 'cab progress made'
	
		def __init__(self, filename):
			self.cabfile = cab.CabCreator(self)
			self.cabfile.create(FileOutputStream(filename))
			folder = cab.CabFolderEntry()
			folder.setCompression(cab.CabConstants.COMPRESSION_LZX, 20)
			#print folder.compressionToString()
コード例 #3
0
===========================================================================
1.0		4/29/10		A Mancevice Initial Coding
"""

# The following global objects are available to the Enhance Rule environment:
# contentManagerService - com.vamosa.content.ContentManagerService
# projectManagerService - com.vamosa.projects.ProjectManagerService
# queryLibrarianService - com.vamosa.query.QueryLibrarianService
# taskLibrarianService  - com.vamosa.process.TaskLibrarianService
# pipelineRunner        - com.vamosa.process.PipelineRunner
# logger                - org.apache.commons.logging.Log
# pipelineName          - java.lang.String containing the name of the pipeline
import sys, os

# add packages from Java into the python module library
sys.add_package("org.python.core")
sys.add_package("com.vamosa.tasks")
sys.add_package("com.vamosa.utils")
sys.add_package("net.sitecore.vamosa")
sys.add_package("com.stellent.www.CheckIn")
sys.add_package("com.stellent.www.Search")
sys.add_package("com.stellent.www.GetFile")
sys.add_package("com.stellent.www.DocInfo")

from com.vamosa.projects import Project
from com.vamosa.tasks import ParameterisedTask
from com.vamosa.utils import DOM4JUtils
from com.vamosa.utils import Base64

from java.io import ByteArrayInputStream
from java.net import URL
コード例 #4
0
#
#A jython library of wrapper routines around the isl interpreter
#

import java

import sys;

sys.add_package('visad');
sys.add_package('visad.python');

sys.add_package('java.util');

from visad.python.JPythonMethods import *
from java.util import ArrayList

def pause():
    idv.waitUntilDisplaysAreDone();


def setOffScreen(offScreen=1):
    idv.getArgsManager().setIsOffScreen(offScreen);

def setDebug(debug=1):
    islInterpreter.setDebug(debug);

# You can provide a python 'dictionary' of datasource:pattern pairs
# which provide the 'setfiles' functionality in the bundle isl tag
def loadBundle(bundleFile, setFilesDict=None, width=-1, height=-1, times="", clear=1):
    if (setFilesDict != None):
      setFiles = ArrayList()
コード例 #5
0
ファイル: modjy_impl.py プロジェクト: kristenjacobs/colin
	def add_packages(self, package_list):
		packages = [p.strip() for p in package_list.split(';')]
		for p in packages:
			self.log.info("Adding java package %s to jython" % p)
			sys.add_package(p)
コード例 #6
0
===========================================================================
1.0		4/29/10		A Mancevice Initial Coding
"""

# The following global objects are available to the Enhance Rule environment:
# contentManagerService - com.vamosa.content.ContentManagerService
# projectManagerService - com.vamosa.projects.ProjectManagerService
# queryLibrarianService - com.vamosa.query.QueryLibrarianService
# taskLibrarianService  - com.vamosa.process.TaskLibrarianService
# pipelineRunner        - com.vamosa.process.PipelineRunner
# logger                - org.apache.commons.logging.Log
# pipelineName          - java.lang.String containing the name of the pipeline
import sys, os

# add packages from Java into the python module library
sys.add_package("org.python.core")
sys.add_package("com.vamosa.tasks")
sys.add_package("com.vamosa.utils")
sys.add_package("net.sitecore.vamosa")
sys.add_package("com.stellent.www.CheckIn")
sys.add_package("com.stellent.www.Search")
sys.add_package("com.stellent.www.GetFile")
sys.add_package("com.stellent.www.DocInfo")

from com.vamosa.projects import Project
from com.vamosa.tasks import ParameterisedTask
from com.vamosa.utils import DOM4JUtils
from com.vamosa.utils import Base64

from java.io import ByteArrayInputStream
from java.net import URL
コード例 #7
0
ファイル: modjy.py プロジェクト: bmaggi/Topcased
# The terms and conditions of this license are listed in a file contained
# in the distribution that also contained this file, under the name
# LICENSE.txt.
#
# You may also read a copy of the license at the following web address.
#
# http://modjy.xhaus.com/LICENSE.txt
#
###

import jarray
import synchronize
import sys
import types

sys.add_package("javax.servlet")
sys.add_package("javax.servlet.http")
sys.add_package("org.python.core")

from modjy_exceptions import *
from modjy_log import *
from modjy_params import modjy_param_mgr, modjy_servlet_params
from modjy_wsgi import modjy_wsgi
from modjy_response import start_response_object
from modjy_impl import modjy_impl
from modjy_publish import modjy_publisher

from javax.servlet.http import HttpServlet


class modjy_servlet(HttpServlet, modjy_publisher, modjy_wsgi, modjy_impl):
コード例 #8
0
#
# I really don't want this to be necessary. I'm not sure why the classpath
# isn't enough. I'm sure I'm not initializing something correctly.
#
import sys

sys.add_package("org.codehaus.plexus.component.factory.jython")

from org.codehaus.plexus.component.factory.jython import Hello


class DefaultHello(Hello):
    def initialize(self):
        print "initialize()"

    def start(self):
        print "start()"

    def stop(self):
        print "stop()"

    def dispose(self):
        print "dispose()"

    def hello(self):
        print "hello!"
コード例 #9
0
##
## osb.py
##
## This script contains functions for interacting with OSB
##

import getopt, sys, os
from java.io import FileInputStream
from java.io import File
from java.util import Date

import sys
import time

sys.add_package("com.bea.wli.config.customization")
from com.bea.wli.config.customization import Customization

# Properties used by script
PROPERTY_OSB_CFGS = "osb.configs"
PROPERTY_OSB_CFG_PREFIX = "osb.config."
PROPERTY_OSB_CFG_SUFFIX_FILE = ".file"
PROPERTY_OSB_CFG_SUFFIX_CUSTOM = ".file.custom"

# OSB Beans
OSB_SESSION_BEAN = "com.bea.wli.sb.management.configuration.SessionManagementMBean"
OSB_CONFIG_BEAN = "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean"

#=======================================================================================
# Load required modules
#=======================================================================================
コード例 #10
0
ファイル: jmxUtils.py プロジェクト: CindyWei/MySleJavaDemo
 This software is distributed under the terms of the MX4J License version 1.0.
 See the terms of the MX4J License in the documentation provided with this software.

 author <a href="mailto:[email protected]">Carlos Quiroz</a>
 version $Revision: 1.1 $
 
 Adapted by Martin Fuzzey for testing use.
 For this we need to communicate with a REMOTE server (the orignal code
 always ran in the same process as the JMX server and was intended to be
 used as helpers for python scripts in the python MBean
 
 """

import sys,java
sys.add_package("javax.management")
sys.add_package("javax.management.loading");
sys.add_package("javax.management.modelmbean");
sys.add_package("javax.management.monitor");
sys.add_package("javax.management.openmbean");
sys.add_package("javax.management.relation");
sys.add_package("javax.management.remote");
sys.add_package("javax.management.remote.rmi");
sys.add_package("javax.management.timer");
from javax.management import *
from javax.management.loading import *
from javax.management.modelmbean import *
from javax.management.monitor import *
from javax.management.openmbean import *
from javax.management.relation import *
from javax.management.remote import *
コード例 #11
0
import sys
import os
idvjar = os.path.join(os.environ['IDV_HOME'], "idv.jar")
visadjar = os.path.join(os.environ['IDV_HOME'], "visad.jar")
sys.packageManager.addJar(idvjar, True)
sys.packageManager.addJar(visadjar, True)
sys.add_package('visad')
sys.add_package('visad.python')
sys.add_package('visad.data.units')
sys.add_package('ucar')
sys.add_package('ucar.unidata.idv')
sys.add_package('ucar.unidata.idv')
sys.add_package('ucar.unidata.ui')

import java

import visad
import visad.python
from visad import *
from visad.python.JPythonMethods import *
import ucar
from java.util import ArrayList
idv = ucar.unidata.idv.IntegratedDataViewer(0)
IdvUIM = idv.getIdvUIManager()

import ucar.unidata.data.grid.GridUtil as GridUtil
import ucar.unidata.data.DataSelection as DataSelection
import ucar.unidata.data.GeoLocationInfo as GeoLocationInfo
import ucar.unidata.data.GeoSelection as GeoSelection

from ucar.unidata.idv.ui import ImageGenerator
コード例 #12
0
ファイル: Output.py プロジェクト: walkabout21/OpenModelSphere
        self.zipfile = ZipOutputStream(FileOutputStream(filename))

    def getName(self, name):
        return string.join(string.split(name, '.'), '/') + '.class'

    def getFile(self, name):
        fname = self.getName(name)
        self.zipfile.putNextEntry(ZipEntry(fname))
        return self.zipfile

    def close(self):
        self.zipfile.close()


try:
    sys.add_package('com.ms.util.cab')
    from com.ms.util import cab
    import com.ms.util.cab.CabCreator
    from java.util import Date

    class CabOutput(cab.CabProgressInterface):
        def progress(self, ptype, val1, val2, data):
            pass
            #print 'cab progress made'

        def __init__(self, filename):
            self.cabfile = cab.CabCreator(self)
            self.cabfile.create(FileOutputStream(filename))
            folder = cab.CabFolderEntry()
            folder.setCompression(cab.CabConstants.COMPRESSION_LZX, 20)
            #print folder.compressionToString()
コード例 #13
0
ファイル: DefaultHello.py プロジェクト: pombredanne/plexus
#
# I really don't want this to be necessary. I'm not sure why the classpath
# isn't enough. I'm sure I'm not initializing something correctly.
#
import sys
sys.add_package("org.codehaus.plexus.component.factory.jython")

from org.codehaus.plexus.component.factory.jython import Hello

class DefaultHello(Hello):
        
    def initialize(self):
        print "initialize()"
        
    def start(self):
        print "start()"

    def stop(self):
        print "stop()"

    def dispose(self):
        print "dispose()"
        
    def hello(self):
        print "hello!"
コード例 #14
0
ファイル: upload.py プロジェクト: guymatz/jython-www
import sys,os,re
from javax.servlet.http import HttpServlet
from java.io import File
#sys.add_package("jxl")
sys.add_package("org.apache.commons.fileupload")
#sys.add_package("org.apache.commons.fileupload.disk")
#sys.add_package("org.apache.commons.fileupload.servlet")
#os.path.append("/usr/share/java/jxl-2.6.12.jar")
from jxl import Workbook
from org.apache.commons.fileupload import *
from org.apache.commons.fileupload.disk import DiskFileItemFactory
from org.apache.commons.fileupload.servlet import ServletFileUpload
from JythonServletUtils import *

class upload (HttpServlet):
  UPLOAD_DIRECTORY="/tmp/uploads"
  def doGet(self,request,response):
    self.doPost (request,response)

  def doPost(self,request,response):
      print("request = %s" % request)
      print("__name__ = %s" % __name__)
      request.setAttribute("message", 'hello')
      request.setAttribute("env", os.environ)
      dispatcher = request.getRequestDispatcher('result.jsp')
      dispatcher.forward(request, response)
#      factory = DiskFileItemFactory()
#      upload = ServletFileUpload(factory)
#      print("dir(upload) = %s" % dir(upload))
#      items = upload.parseRequest(request)
#      if ServletFileUpload.isMultipartContent(request):
コード例 #15
0
ファイル: modjy.py プロジェクト: abhijangda/DacapoInputSets
# The terms and conditions of this license are listed in a file contained
# in the distribution that also contained this file, under the name
# LICENSE.txt.
# 
# You may also read a copy of the license at the following web address.
# 
# http://modjy.xhaus.com/LICENSE.txt
#
###

import jarray
import synchronize
import sys
import types

sys.add_package("javax.servlet")
sys.add_package("javax.servlet.http")
sys.add_package("org.python.core")

from modjy_exceptions import *
from modjy_log import *
from modjy_params import modjy_param_mgr, modjy_servlet_params 
from modjy_wsgi import modjy_wsgi
from modjy_response import start_response_object
from modjy_impl import modjy_impl
from modjy_publish import modjy_publisher

from	javax.servlet.http	import HttpServlet

class modjy_servlet(HttpServlet, modjy_publisher, modjy_wsgi, modjy_impl):
コード例 #16
0
import os
import sys

# get the nexiles jython package into the path.
for index, p in enumerate(sys.path):
    if ".jar" in p:
        site_packages_dir = os.path.join(p, "site-packages")
        sys.path.insert(index + 1, site_packages_dir)

        # also add pip and distribute
        sys.path.append(site_packages_dir + "/distribute-0.6.31-py2.5.egg")
        sys.path.append(site_packages_dir + "/pip-1.2.1-py2.5.egg")
        break

sys.add_package("org.json")
sys.add_package("org.json.simple")
sys.add_package("org.json.simple.parser")

from monkey import patch
patch()

# add WEB-INF/lib-python as site dir if we have a WT_HOME
if "WT_HOME" in os.environ:
    from site import addsitedir

    WT_HOME = os.environ["WT_HOME"]
    addsitedir(os.path.join(WT_HOME, "codebase", "WEB-INF", "lib-python"))

    if "SETUP_WT_CLASSPATH" in os.environ:
        import wt_classpath
コード例 #17
0
ファイル: jythonrc.py プロジェクト: suvarchal/JyIDV
import sys
import os
idvjar=os.path.join(os.environ['IDV_HOME'],"idv.jar")
visadjar=os.path.join(os.environ['IDV_HOME'],"visad.jar")
sys.packageManager.addJar(idvjar,True)
sys.packageManager.addJar(visadjar,True)
sys.add_package('visad')
sys.add_package('visad.python')
sys.add_package('visad.data.units')
sys.add_package('ucar')
sys.add_package('ucar.unidata.idv')
sys.add_package('ucar.unidata.idv')
sys.add_package('ucar.unidata.ui')

import java

import visad
import visad.python
from visad import *
from visad.python.JPythonMethods import *
import ucar
from java.util import ArrayList
#idv=ucar.unidata.idv.IntegratedDataViewer(0)
idv=ucar.unidata.idv.DefaultIdv([])
IdvUIM=idv.getIdvUIManager()

import ucar.unidata.data.grid.GridUtil as GridUtil
import ucar.unidata.data.DataSelection as DataSelection
import ucar.unidata.data.GeoLocationInfo as GeoLocationInfo
import ucar.unidata.data.GeoSelection as GeoSelection
コード例 #18
0
ファイル: __init__.py プロジェクト: jdeck88/ontopilot
# Add the paths to all of the required java libraries to the classpath.  If
# OntoPilot is run from a standalone JAR file, the java libraries will
# automatically be in the classpath, the java-lib directory will be
# non-existent, and jlibpaths will therefore be an empty list, so the classpath
# will not be modified here.
scriptdir = os.path.dirname(os.path.realpath(__file__))
jlibdir = os.path.realpath(
    os.path.join(scriptdir, '..', '..', 'java-lib', '*.jar'))
jlibpaths = glob.glob(jlibdir)
for jlibpath in jlibpaths:
    sys.path.append(jlibpath)

# Import Java logging components.  We first need to register the log4j JAR file
# using add_package() so we can do a package-level import.
sys.add_package('org.apache.log4j')
from org.apache import log4j

# Configure log4j and set the root logging level to WARN.  Without these lines,
# using the ELK reasoner (version 0.4.3) will trigger a warning about log4j not
# being configured, and then, once log4j is configured, it will print all
# messages to the console by default, so the logging level needs to be set.
log4j.BasicConfigurator.configure()
log4j.Logger.getRootLogger().setLevel(log4j.Level.WARN)

# Initialize the logger for this package.
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

# Create the custom handler and apply it to the root logger.  If the custom
# handler is instead attached to the package logger, then logging  messages
コード例 #19
0
#----------------------------------------------------------------------------------------
import java
from java.lang import System
from java.io import *
from javax.swing import *
from java.awt import *
from java.awt.event import *
from javax.swing.event import *
import java

from java.rmi import *
#from java.rmi.server import UnicastRemoteObject
from org.python.rmi import UnicastRemoteObject

import sys
sys.add_package ('org.systemsbiology.gaggle')
import org.systemsbiology.gaggle as gaggle
#----------------------------------------------------------------------------------------
def version ():
  print 'Tuesday, 21 December 2004'
#----------------------------------------------------------------------------------------
class ControlPanel (JFrame, WindowListener, ActionListener, gaggle.Goose, UnicastRemoteObject):

  def __init__ (self):

    JFrame.__init__ (self, title='Inferelator Control Panel', size = (200, 200))
    self.name = 'Inferelator'
    self.setDefaultCloseOperation (JFrame.DISPOSE_ON_CLOSE)
    self.addWindowListener (self)
  
    self.getContentPane().add (self.createGui ())
コード例 #20
0
1.0		5/27/2010	A mancevice	Initial Coding
"""

# The following global objects are available to the Enhance Rule environment:
# contentManagerService - com.vamosa.content.ContentManagerService
# projectManagerService - com.vamosa.projects.ProjectManagerService
# queryLibrarianService - com.vamosa.query.QueryLibrarianService
# taskLibrarianService  - com.vamosa.process.TaskLibrarianService
# pipelineRunner		- com.vamosa.process.PipelineRunner
# logger				- org.apache.commons.logging.Log
# pipelineName		  - java.lang.String containing the name of the pipeline

import sys, re

# add packages from Java into the python module library
sys.add_package("org.python.core")
sys.add_package("com.vamosa.tasks")
sys.add_package("com.vamosa.utils")
sys.add_package("com.vamosa.moss2010")

from com.vamosa.tasks import ParameterisedTask
from com.vamosa.utils import DOM4JUtils
from com.vamosa.utils import Base64
from com.vamosa.moss2010 import SharePointServiceLocator
from java.net import URL

class MyParameterisedClass(ParameterisedTask):
	def usage(self):
		self.requiresContentDescriptor("contentDescriptor", "the default content descriptor")
		self.requiresContent("content", "the default content")
		self.requiresString("local_service_url","URL of local service for SharePoint (eg. \"http://localhost/sharepoint.asmx?wsdl\")")
コード例 #21
0
 This software is distributed under the terms of the MX4J License version 1.0.
 See the terms of the MX4J License in the documentation provided with this software.

 author <a href="mailto:[email protected]">Carlos Quiroz</a>
 version $Revision: 1.1 $
 
 Adapted by Martin Fuzzey for testing use.
 For this we need to communicate with a REMOTE server (the orignal code
 always ran in the same process as the JMX server and was intended to be
 used as helpers for python scripts in the python MBean
 
 """

import sys, java
sys.add_package("javax.management")
sys.add_package("javax.management.loading")
sys.add_package("javax.management.modelmbean")
sys.add_package("javax.management.monitor")
sys.add_package("javax.management.openmbean")
sys.add_package("javax.management.relation")
sys.add_package("javax.management.remote")
sys.add_package("javax.management.remote.rmi")
sys.add_package("javax.management.timer")
from javax.management import *
from javax.management.loading import *
from javax.management.modelmbean import *
from javax.management.monitor import *
from javax.management.openmbean import *
from javax.management.relation import *
from javax.management.remote import *
コード例 #22
0
##
## osb.py
##
## This script contains functions for interacting with OSB
##

import getopt, sys, os
from java.io import FileInputStream
from java.io import File
from java.util import Date

import sys
import time

sys.add_package("com.bea.wli.config.customization")
from com.bea.wli.config.customization import Customization

# Properties used by script
PROPERTY_OSB_CFGS = "osb.configs"
PROPERTY_OSB_CFG_PREFIX = "osb.config."
PROPERTY_OSB_CFG_SUFFIX_FILE = ".file"
PROPERTY_OSB_CFG_SUFFIX_CUSTOM = ".file.custom"

# OSB Beans
OSB_SESSION_BEAN = "com.bea.wli.sb.management.configuration.SessionManagementMBean"
OSB_CONFIG_BEAN = "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean"

#=======================================================================================
# Load required modules
#=======================================================================================