当前位置: 首页>>代码示例>>Python>>正文


Python repyhelper.translate_and_import函数代码示例

本文整理汇总了Python中repyhelper.translate_and_import函数的典型用法代码示例。如果您正苦于以下问题:Python translate_and_import函数的具体用法?Python translate_and_import怎么用?Python translate_and_import使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了translate_and_import函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_api_key

 def _get_api_key(self, username, private_key_string):
   # Normally we try not to import modules anywhere but globally,
   # but I'd like to keep this xmlrpc client usable without repy files
   # available when the user provides their api key and doesn't require
   # it to be retrieved.
   try:
     import repyhelper
     import repyportability
     repyhelper.translate_and_import("rsa.repy")
   except ImportError, e:
     raise SeattleClearinghouseError("Unable to get API key from SeattleClearinghouse " +
                            "because a required python or repy module " + 
                            "cannot be found:" + str(e))
开发者ID:Ashmita89,项目名称:attic,代码行数:13,代码来源:seattleclearinghouse_xmlrpc.py

示例2: add_dy_support

def add_dy_support(_context):
  # Add dylink support
  repyhelper.translate_and_import("dylink.repy", callfunc = 'initialize')
  
  # The dy_* functions are only added to the namespace after init_dylink is called.
  init_dylink(_context,{})
  
  # Make our own `dy_import_module_symbols` and  add it to the context.
  # It is not currently possible to use the real one (details at ticket #1046)
  def _dy_import_module_symbols(module,new_callfunc="import"):
    new_context = _context['dy_import_module'](module, new_callfunc)._context
    # Copy in the new symbols into our namespace.
    for symbol in new_context:  
      if symbol not in _context: # Prevent the imported object from destroying our namespace.
        _context[symbol] = new_context[symbol]

  _context['dy_import_module_symbols'] = _dy_import_module_symbols
开发者ID:ohmann,项目名称:checkapi,代码行数:17,代码来源:repyportability.py

示例3: except

import shutil

# clean up any left over data...
try:
  shutil.rmtree('sourcepathtest')
except (OSError, IOError):
  # it's okay if it doesn't exist...
  pass

os.mkdir('sourcepathtest')

# prepend this to the Python path...
sys.path = ['sourcepathtest'] + sys.path

# remove the file if it's there...
if os.path.exists('rhtest_filetests_repy.py'):
  os.remove('rhtest_filetests_repy.py')

# write files there
repyhelper.translate_and_import('rhtest_filetests.repy')

# This should work...
try:
  rhtest_filetests_exists()
except NameError:
  print "Failed to import rhtest_filetests when using sourcepath test"

# and the file should be in the current directory.
if not os.path.exists('rhtest_filetests_repy.py'):
  print "The rhtest_filetests.repy file was not preprocessed to the current directory because 'rhtest_filetests_repy.py' does not exist"
开发者ID:Ashmita89,项目名称:attic,代码行数:30,代码来源:py_z_test_sourcepath.py

示例4: rsa_gen_pubpriv_keys

    PyCrypto which is authored by Dwayne C. Litzenberger
    
    Seattle's origional rsa.repy which is Authored by:
      Adapted by Justin Cappos from the version by:
        author = "Sybren Stuvel, Marloes de Boer and Ivo Tamboer"

<Purpose>
  This is the main interface for using the ported RSA implementation.
    
<Notes on port>
  The random function can not be defined with the initial construction of
  the RSAImplementation object, it is hard coded into number_* functions.
    
"""

repyhelper.translate_and_import('random.repy')
repyhelper.translate_and_import('pycryptorsa.repy')
    
     
        
def rsa_gen_pubpriv_keys(bitsize):
  """
  <Purpose>
    Will generate a new key object with a key size of the argument
    bitsize and return it. A recommended value would be 1024.
   
  <Arguments>
    bitsize:
           The number of bits that the key should have. This
           means the modulus (publickey - n) will be in the range
           [2**(bitsize - 1), 2**(bitsize) - 1]           
开发者ID:Albinpa,项目名称:MPCSN,代码行数:31,代码来源:rsa_repy.py

示例5: server

mycontext = repyhelper.get_shared_context()
callfunc = 'import'
callargs = []

""" 
Author: Justin Cappos

Start Date: July 8, 2008

Description:
Advertisements to a central server (similar to openDHT)


"""

repyhelper.translate_and_import('session.repy')
# I'll use socket timeout to prevent hanging when it takes a long time...
repyhelper.translate_and_import('sockettimeout.repy')
repyhelper.translate_and_import('serialize.repy')


# Hmm, perhaps I should make an initialization call instead of hardcoding this?
# I suppose it doesn't matter since one can always override these values
servername = "advertiseserver.poly.edu"
# This port is updated to use the new port (legacy port is 10101)
serverport = 10102




class CentralAdvertiseError(Exception):
开发者ID:drewwestrick,项目名称:Repy-Web-Server,代码行数:31,代码来源:centralizedadvertise_repy.py

示例6: retrieve_url

    emailed when something goes wrong

  This script takes no arguments. A typical use of this script is to
  have it run periodically using something like the following crontab line:
  7 * * * * /usr/bin/python /home/seattle/centralizedputget.py > /home/seattle/cron_log.centralizedputget
"""

import urllib
import send_gmail
import integrationtestlib
import urllib2
import subprocess


import repyhelper
repyhelper.translate_and_import('serialize.repy')


username = 'selexor_monitor'
apikey = '1X3YFBLPTKVSI8DQHWJZ0NR92645ECUA'

userdata = {username: {'apikey': apikey}}

ERROR_EMAIL_SUBJECT = "Selexor monitoring test failure!"
SELEXOR_PAGE = "https://selexor.poly.edu:8888/"


def retrieve_url(url, data=None):
  print "retrieve_url"
  args = ["curl", url, "--insecure"]
  if data:
开发者ID:aot221,项目名称:integrationtests,代码行数:31,代码来源:selexor_active.py

示例7:

"""
Performs initialization for the bundle unit tests.

It should create bundles that contains 3 files: src1, src2, and src3.
"""

import bundle_test_helper
import repyhelper
repyhelper.translate_and_import('bundle.repy')

# Tests shouldn't modify this file directly
# They should make a copy if they need to modify this file.

TEST_BUNDLE_FN = 'test_readonly.bundle.repy'
TEST_EMBED_BUNDLE_FN = 'test_embedded_readonly.bundle.repy'
EMBED_SCRIPT_FN = 'testscript.repy'
TEST_FILENAMES = ['src1', 'src2', 'src3']
TEST_COPY_FILENAMES = ['src1copy', 'src2copy', 'src3copy']

# Make sure the bundle doesn't exist to test bundle creation
bundle_test_helper.remove_files_from_directory([TEST_BUNDLE_FN])

bundle_test_helper.prepare_test_sourcefiles()


test_bundle = bundle_Bundle(TEST_BUNDLE_FN, 'w')
test_bundle.add_files(TEST_COPY_FILENAMES)
test_bundle.close()

test_bundle = bundle_Bundle(TEST_EMBED_BUNDLE_FN, 'w', srcfn=EMBED_SCRIPT_FN)
test_bundle.add_files(TEST_COPY_FILENAMES)
开发者ID:SeattleTestbed,项目名称:seattlelib_v1,代码行数:31,代码来源:ut_bundle_setup.py

示例8: fix

    of random bytes, this is not a permanent fix (the extraction 
    of random bytes from the float is not portable). The change will
    likely be made to random_randombytes (since calls os.urandom will
    likely be restricted to a limited number of bytes).  
  TODO - 
    random_randombytes will remained but serve as a helper function
    to collect the required number of bytes. Calls to randombytes
    will be restricted to a set number of bytes at a time, since
    allowing an arbitrary request to os.urandom would circumvent 
    performance restrictions. 
  TODO - 
    _random_long_to_bytes will no longer be needed.  
      
"""

repyhelper.translate_and_import('math.repy')

def random_randombytes(num_bytes, random_float=None):
  """
   <Purpose>
     Return a string of length num_bytes, made of random bytes 
     suitable for cryptographic use (because randomfloat draws
     from a os provided random source).
      
     *WARNING* If python implements float as a C single precision
     floating point number instead of a double precision then
     there will not be 53 bits of data in the coefficient.

   <Arguments>
     num_bytes:
               The number of bytes to request from os.urandom. 
开发者ID:Albinpa,项目名称:MPCSN,代码行数:31,代码来源:random_repy.py

示例9:

<Purpose>
  This file provides the encryption functionality for rsa.repy. 
  This code has been left as close to origional as possible with
  the notes about changes made to enable for easier modification
  if pycrypto is updated. 
  
  It contains:
    pubkey.py
    RSA.py 
    _RSA.py
    _slowmath.py
    number.py

"""

repyhelper.translate_and_import('random.repy')

#
#   pubkey.py : Internal functions for public key operations
#
#  Part of the Python Cryptography Toolkit
#
# Distribute and use freely; there are no restrictions on further
# dissemination and usage except those imposed by the laws of your
# country of residence.  This software is provided "as is" without
# warranty of fitness for use or suitability for any purpose, express
# or implied. Use at your own risk or not at all.
#

"""
<Modified>
开发者ID:stredger,项目名称:viewpoints,代码行数:31,代码来源:pycryptorsa_repy.py

示例10: NOTE

This module is adapted from code in seash which had similar functionality.

NOTE (for the programmer using this module).   It's really important to 
write concurrency safe code for the functions they provide us.  It will not 
work to write:

def foo(...):
  mycontext['count'] = mycontext['count'] + 1

YOU MUST PUT A LOCK AROUND SUCH ACCESSES.

"""


# I use this to get unique identifiers. 
repyhelper.translate_and_import('uniqueid.repy')



class ParallelizeError(Exception):
  """An error occurred when operating on a parallelized task"""


# This has information about all of the different parallel functions.
# The keys are unique integers and the entries look like this:
# {'abort':False, 'callfunc':callfunc, 'callargs':callargs,
# 'targetlist':targetlist, 'availabletargetpositions':positionlist,
# 'runninglist':runninglist, 'result':result}
#
# abort is used to determine if future events should be aborted.
# callfunc is the function to call
开发者ID:VitoInfinito,项目名称:tda596,代码行数:31,代码来源:parallelize_repy.py

示例11: add_vessel

      - acquires log output from vessels and stores them in state for user

  This is a general interface with connecting with remote Seattle instances
  directly, but the functionality is geared toward the needs of the
  autograder.

"""

import sys 
import nmAPI

from repyportability import *

import repyhelper

repyhelper.translate_and_import("nmclient.repy")
repyhelper.translate_and_import("rsa.repy")
repyhelper.translate_and_import("parallelize.repy")

# global state
key = {}
vesselinfo = {}

# the default Seattle instance to connect to
DEFAULT_NODEMANAGER_PORT = 1224

# alpers - adds a vessel and its information to the overall vessel dict
#          (from seash.mix); this is strictly internal.
def add_vessel(longname, vesselhandle):
    vesselinfo[longname] = {}
    vesselinfo[longname]['handle'] = vesselhandle
开发者ID:Ashmita89,项目名称:attic,代码行数:31,代码来源:nm_remote_api.py

示例12: geoip_client

  Evan Meagher

<Start Date>
  Nov 26, 2009

<Description>
  XMl-RPC client for remote GeoIP server. Given an IP:port of a GeoIP
  XML-RPC server, allows location lookup of hostnames and IP addresses.

<Usage>
  client = geoip_client(server_address)

  Where server_address is the ip address of a remote GeoIP XMl-RPC server.
"""

repyhelper.translate_and_import('parallelize.repy')
repyhelper.translate_and_import('xmlrpc_client.repy')


"""
Initialize global GeoIP XML-RPC client object to None
Note: client is stored in wrapper list to avoid using mycontext dict
"""
geoip_clientlist = []



def geoip_init_client(url=["http://geoipserver.poly.edu:12679", "http://geoipserver2.poly.edu:12679"]):
  """
  <Purpose>
    Create a new GeoIP XML-RPC client object.
开发者ID:Albinpa,项目名称:MPCSN,代码行数:31,代码来源:geoip_client_repy.py

示例13: num_callargs

"""
Test the callargs parameter of the translation calls, to make sure it actually
gets used

"""

import repyhelper
import test_utils

TESTFILE = "rhtest_callargs2.r2py"

#Make sure we have fresh translations per test run
test_utils.cleanup_translations([TESTFILE])

repyhelper.translate_and_import(TESTFILE, callargs=['a', 'samoas', 'c'])
if num_callargs() is not 3:
  print "translate_and_import had wrong number of callargs:", num_callargs() 

test_utils.cleanup_translations([TESTFILE])
开发者ID:Ashmita89,项目名称:attic,代码行数:19,代码来源:py_z_test_callargs2.py

示例14: except

# clean up any left over data...
try:
  shutil.rmtree('importcachetest')
except (OSError, IOError):
  # it's okay if it doesn't exist...
  pass

os.mkdir('importcachetest')

# append this to the Python path...
sys.path = sys.path +  ['importcachetest']

# write files there
repyhelper.set_importcachedir('importcachetest')

repyhelper.translate_and_import('rhtestrecursion_1.r2py')

# This should work...
try:
  # note: this is a function from rhtest_recursion_1.   I'm not calling it...
  one
except NameError:
  print "Failed to import rhtest_recursion_1 when using importcachetest"

# This should work...
try:
  # note: this is a function from rhtest_recursion_2.   I'm not calling it...
  two
except NameError:
  print "Failed to import rhtest_recursion_2 when using importcachetest"
开发者ID:Ashmita89,项目名称:attic,代码行数:30,代码来源:py_z_test_importcachedir_recursive.py

示例15: file

"""
Test the filename parameter of the translation calls, to make sure errors are
handled well.

"""

import repyhelper



try:
  repyhelper.translate_and_import('asdkfjaNONEXISTANT_FILEkasfj')
except ValueError:
  pass
else:
  print "Was able to import a nonexistant file (no dir)..."



try:
  repyhelper.translate_and_import('./asdkfjaVALID_DIR_NONEXISTANT_FILEkasfj')
except ValueError:
  pass
else:
  print "Was able to import a nonexistant file in a valid dir..."


try: 
  repyhelper.translate_and_import('asaINVALID_DIRkasd/adjNONEXISTANT_FILEkaj')
except ValueError:
  pass
开发者ID:Ashmita89,项目名称:attic,代码行数:31,代码来源:py_z_test_badimports.py


注:本文中的repyhelper.translate_and_import函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。