コード例 #1
0
ファイル: wsgiapp.py プロジェクト: UfSoft/ISPManCCP-V2
    def __init__(self):
        """One instance of Globals is created during application
        initialization and is available during requests via the 'g'
        variable.
        """


        try:
            import perl
        except ImportError:
            print "You need the pyperl module installed."
            print "You can get it from the ISPManSOAP source"
            sys.exit(1)
        self.perl = perl

        log.debug('Perl Is Now Setup')

        ispman_installdir = os.path.abspath(config['app_conf']['ispman_base_dir'])

        # Get Perl's @INC reference
        inc = perl.get_ref("@INC")
        # Add ISPMan lib directory to perl's @INC
        ispman_libs = os.path.join(ispman_installdir, 'lib')
        inc.append(ispman_libs)
        # Setup an ISPMan instance
        perl.require('ISPMan')
        perl.require('CGI')

        try:
            ispman_perl = perl.eval(
                '$ENV{"HTTP_USER_AGENT"} = "PYTHON-CCP"; ' +
                '$ispman = ISPMan->new() or die "$@"'
            )
        except Exception, e:
            print e
コード例 #2
0
ファイル: app_globals.py プロジェクト: UfSoft/ISPManCCP
    def __init__(self):
        """One instance of Globals is created during application
        initialization and is available during requests via the 'g'
        variable
        """
        ispman_installdir = os.path.abspath(config['app_conf']['ispman_base_dir'])
        check_path_perms(ispman_installdir)

        try:
            import perl
        except ImportError:
            print "You need the pyperl module installed."
            print "You can get it from:"
            print "   http://www.felix-schwarz.name/files/opensource/pyperl/"
            sys.exit(1)

        # Get Perl's @INC reference
        inc = perl.get_ref("@INC")

        # Add ISPMan lib directory to perl's @INC
        ispman_libs = os.path.join(ispman_installdir, 'lib')
        check_path_perms(ispman_libs)
        inc.append(ispman_libs)
        # Setup an ISPMan instance
        perl.require('ISPMan')
        perl.require('CGI')

        try:
            # Make ISPMan recognize us as a Control Panel
            self.ispman = perl.eval(
                '$ENV{"HTTP_USER_AGENT"} = "PYTHON-CCP"; ' +
                '$ispman = ISPMan->new() or die "$@"'
            )
        except Exception, e:
            print e
コード例 #3
0
ファイル: knab.py プロジェクト: B-Rich/ibid-1
    def __init__(self, name):
        Processor.__init__(self, name)

        perl.eval('use lib "%s"' % self.knabdir)
        perl.require('Knab::Dumper')
        perl.require('Knab::Conf')
        perl.require('Knab::Modules')
        perl.require('Knab::Processor')
        perl.eval('$::dumper=new Knab::Dumper();')
        perl.eval('$::config = new Knab::Conf(Basedir=>"%s", Filename=>"%s");' % (self.knabdir, self.config))
        factoidDB = perl.eval('$::config->getValue("FactoidDB/module");')
        perl.require(factoidDB)
        perl.eval('$::db=new %s();' % factoidDB)
        modules = perl.callm('new', 'Knab::Modules')
        self.processor = perl.callm('new', 'Knab::Processor', modules)
コード例 #4
0
ファイル: knab.py プロジェクト: shoosen/ibid
    def __init__(self, name):
        Processor.__init__(self, name)

        perl.eval('use lib "%s"' % self.knabdir)
        perl.require('Knab::Dumper')
        perl.require('Knab::Conf')
        perl.require('Knab::Modules')
        perl.require('Knab::Processor')
        perl.eval('$::dumper=new Knab::Dumper();')
        perl.eval(
            '$::config = new Knab::Conf(Basedir=>"%s", Filename=>"%s");' %
            (self.knabdir, self.config))
        factoidDB = perl.eval('$::config->getValue("FactoidDB/module");')
        perl.require(factoidDB)
        perl.eval('$::db=new %s();' % factoidDB)
        modules = perl.callm('new', 'Knab::Modules')
        self.processor = perl.callm('new', 'Knab::Processor', modules)
コード例 #5
0
def perl_require(mod):
    # Some caching since the real 'perl.require' is a bit
    # heavy.
    global INC
    try:
        return INC[mod]
    except KeyError:
        pass

    import perl
    INC[mod] = perl.require(mod)
    return INC[mod]
コード例 #6
0
ファイル: perlmod.py プロジェクト: chiptip/pyperl
def perl_require(mod):
    # Some caching since the real 'perl.require' is a bit
    # heavy.
    global INC
    try:
        return INC[mod]
    except KeyError:
        pass

    import perl

    INC[mod] = perl.require(mod)
    return INC[mod]
コード例 #7
0
ファイル: dbi2.py プロジェクト: shlomif/pyperl
    def __init__(self, dsn, user=None, password=None):
        global perl
        if not perl:
            import perl
            perl.require("DBI")

        conf = perl.get_ref("%")
        conf["RaiseError"] = 0
        conf["PrintError"] = 0
        conf["AutoCommit"] = 1

        self.dbh = perl.callm("connect", "DBI", dsn, user, password, conf)
        if self.dbh is None:
            raise OperationalError(perl.eval("$DBI::errstr"))

        self.dbh["RaiseError"] = 1

        try:
            self.dbh["AutoCommit"] = 0
            self.autocommit = 0
        except:
            self.autocommit = 1
コード例 #8
0
ファイル: dbi2.py プロジェクト: UfSoft/ISPMan-Twisted-Flex
    def __init__(self, dsn, user=None, password=None):
        global perl
        if not perl:
            import perl
            perl.require("DBI")

        conf = perl.get_ref("%")
        conf["RaiseError"] = 0
        conf["PrintError"] = 0
        conf["AutoCommit"] = 1

        self.dbh = perl.callm("connect", "DBI", dsn, user, password, conf)
        if self.dbh is None:
            raise OperationalError, perl.eval("$DBI::errstr")

        self.dbh["RaiseError"] = 1
        
        try:
            self.dbh["AutoCommit"] = 0
            self.autocommit = 0
        except:
            self.autocommit = 1
コード例 #9
0
ファイル: perlmod.py プロジェクト: ByReaL/pyperl
def perl_require(mod):
    # Some caching since the real 'perl.require' is a bit
    # heavy.
    id = get_ident()
    global INC
    try:
        return INC[id][mod]
    except KeyError:
        pass
    
    import perl
    if id not in INC:
        INC[id] = {}
    INC[id][mod] = perl.require(mod)
    return INC[id][mod]
コード例 #10
0
ファイル: perlmod.py プロジェクト: hroest/python-perlmodule
def perl_require(mod):
    # Some caching since the real 'perl.require' is a bit
    # heavy.
    id = get_ident()
    global INC
    try:
        return INC[id][mod]
    except KeyError:
        pass
    
    import perl
    if not INC.has_key(id):
        INC[id] = {}
    INC[id][mod] = perl.require(mod)
    return INC[id][mod]
コード例 #11
0
import shutil,os,perl,string,fnmatch,re,time
from drakx.common import *
perl.require("URPM")
perl.require("urpm")
perl.require("urpm::select")

class Distribution(object):
    def __init__(self, config, arch, media, includelist, excludelist, rpmsrate, compssusers, filedeps, suggests = False, synthfilter = ".cz:gzip -9", root="/usr/lib64/drakx-installer/root", stage1=None, stage2=None, advertising=None, gpgName=None, gpgPass=None):
        volumeid = ("%s-%s-%s-%s" % (config.vendor, config.product, config.version, arch)).upper()
        if len(volumeid) > 32:
            print("length of volumeid '%s' (%d) > 32" % (volumeid, len(volumeid)))
            exit(1)
        self.arch = arch
        self.media = {}
        for m in media:
            self.media[m.name] = m

        tmpdir = config.tmpdir+"/"+arch
        repopath = config.repopath+"/"+self.arch
        config.rootdir = root

        print(color("Parsing lists of packages to include", GREEN))
        includes = []
        for pkglf in includelist:
            f = open(pkglf)
            for line in f.readlines():
                line = line.strip()
                if not line or line[0] == "#":
                    continue
                if line.startswith("CAT_"):
                    category, weight = line.split()
コード例 #12
0
ファイル: perlpickle.py プロジェクト: vadrer/pyperl
# After this module is loaded, perl object can be pickled
# The perl objects can even contain python objects that contain
# perl objects that contain python objects that...
#
# You are not supposed to use any functions from this module.
# Just use Pickle as usual.
#
# Copyright 2000-2001 ActiveState

import perl
perl.require("Storable")
perl.callm("VERSION", "Storable", 0.7)

storable_thaw = perl.get_ref("Storable::thaw")
storable_nfreeze = perl.get_ref("Storable::nfreeze")


def perl_restore(frozen):
    return storable_thaw(frozen)


def perl_reduce(o):
    return (perl_restore, (storable_nfreeze(o), ))


import copyreg
copyreg.pickle(type(perl.get_ref("$")), perl_reduce, perl_restore)
del (copy_reg)

from pickle import dumps, loads
コード例 #13
0
      if not row:
          break
      print row

The object returned by connect() is actually the Perl DBI datahandle
object.  This means that the interface provided with be exactly like
that of the Perl DBI.  Extended documentation on DBI available from
the 'perldoc DBI' command.

The dbi2 module provide an interface to Perl DBI that conforms to
Python's own DB API.
"""

import perl

perl.require("DBI")


def connect(data_source, username, password="", **attr):
    """Make a new connection to the database

The first parameter is the data_source string (something beginning with "DBI:").
Then there is a username and a password and at last other named configuration
parameters like; RaiseError, PrintError and AutoCommit.
"""
    dbh = perl.callm("connect", "DBI", data_source, username, password,
                     dict2hash(attr))
    return dbh


def available_drivers():
コード例 #14
0
ファイル: dbi.py プロジェクト: ByReaL/pyperl
      if not row:
          break
      print row

The object returned by connect() is actually the Perl DBI datahandle
object.  This means that the interface provided with be exactly like
that of the Perl DBI.  Extended documentation on DBI available from
the 'perldoc DBI' command.

The dbi2 module provide an interface to Perl DBI that conforms to
Python's own DB API.
"""

import perl

perl.require("DBI")


def connect(data_source, username, password="", **attr):
    """Make a new connection to the database

The first parameter is the data_source string (something beginning with "DBI:").
Then there is a username and a password and at last other named configuration
parameters like; RaiseError, PrintError and AutoCommit.
"""
        dbh = perl.callm("connect", "DBI", data_source, username, password,
                        dict2hash(attr))
    return dbh

def available_drivers():
    return perl.callm_tuple("available_drivers", "DBI")
コード例 #15
0
ファイル: distribution.py プロジェクト: azioga/drakx
import shutil,os,perl,string,fnmatch,re,time,urllib2
from drakx.common import *
perl.require("URPM")
perl.require("urpm")
perl.require("urpm::select")

class Distribution(object):
    def __init__(self, config, arch, media, includelist, excludelist, rpmsrate, compssusers, filedeps, suggests = False, synthfilter = ".cz:gzip -9", root="/usr/lib64/drakx-installer/root", stage1=None, stage2=None, advertising=None, gpgName=None, gpgPass=None):
        volumeid = ("%s-%s-%s-%s" % (config.vendor, config.product, config.version, arch)).upper()
        if len(volumeid) > 32:
            print "length of volumeid '%s' (%d) > 32" % (volumeid, len(volumeid))
            exit(1)
        self.arch = arch
        self.media = {}
        for m in media:
            self.media[m.name] = m

        tmpdir = config.tmpdir+"/"+arch
        repopath = config.repopath+"/"+self.arch
        config.rootdir = root

        print color("Parsing lists of packages to include", GREEN)
        includes = []
        for pkglf in includelist:
            f = open(pkglf)
            for line in f.readlines():
                line = line.strip()
                if not line or line[0] == "#":
                    continue
                if line.startswith("CAT_"):
                    category, weight = line.split()
コード例 #16
0
import perl
perl.require("LWP::Simple")
get = perl.get_ref("LWP::Simple::get")

doc = get("http://www.python.org")
print doc
コード例 #17
0
ファイル: URPM.py プロジェクト: proyvind/mdvcheck
import perl

perlmod = perl.require("URPM")


class URPM(object):
    def __init__(self):
        self.urpm = perl.callm("new", "URPM")
        self.pkgs = []

    def parse_hdlist(self, path, packing=0, keep_all_tags=0):
        return perl.callm_tuple("parse_hdlist", self.urpm, path, {packing: packing, keep_all_tags: keep_all_tags})

    def __ret(self, pkg):
        self.pkgs.append(Package(pkg))

    def load(self):
        perl.callm_tuple("traverse", self.urpm, self.__ret)


class DB(object):
    def __init__(self, path=None, write=0):
        self.db = perl.callm_tuple("open", "URPM::DB", path, write)

    def __ret(self, pkg):
        self.pkgs.append(Package(pkg))

    def load(self):
        perl.callm_tuple("traverse", self.db, self.__ret)