Beispiel #1
0
import os
import sys
import daemon
import optparse


import repyhelper #used to bring in NAT Layer

# I need to make a cachedir for repyhelper...
if not os.path.exists('nodemanager.repyhelpercache'):
  os.mkdir('nodemanager.repyhelpercache')

# prepend this to my python path
sys.path = ['nodemanager.repyhelpercache'] + sys.path
repyhelpercachedir = repyhelper.set_importcachedir('nodemanager.repyhelpercache')



# Armon: Prevent all warnings
import warnings
# Ignores all warnings
warnings.simplefilter("ignore")

from repyportability import *

import time

import threading

import nmadvertise
Beispiel #2
0
"""
Test if bad calls to importcachedir are handled.

"""

import repyhelper

try:
    repyhelper.set_importcachedir(153)
except TypeError:
    pass
else:
    print "Was able to set the cache dir to be something besides a string..."

try:
    repyhelper.set_importcachedir('asdkfjaNONEXISTANT_DIRasfj')
except TypeError:
    pass
else:
    print "Was able to set my cache to a nonexistant dir..."

try:
    repyhelper.set_importcachedir('..')
except ValueError:
    pass
else:
    print "Was able to set my cache to be a dir that's not in the python path..."

try:
    repyhelper.translate_and_import('./asdkfjaVALID_DIR_NONEXISTANT_FILEkasfj')
except ValueError:
import shutil

# 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:
Beispiel #4
0
import shutil

# 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.repy')

# 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:
  is_android = True
except ImportError:
  is_android = False


import daemon

import repyhelper

# I need to make a cachedir for repyhelper...
if not os.path.exists('softwareupdater.repyhelpercache'):
  os.mkdir('softwareupdater.repyhelpercache')

# prepend this to my python path
sys.path = ['softwareupdater.repyhelpercache'] + sys.path
repyhelpercachedir = repyhelper.set_importcachedir('softwareupdater.repyhelpercache')


# this is being done so that the resources accounting doesn't interfere with logging
from repyportability import *

import urllib      # to retrieve updates
import random
import shutil
import socket   # we'll make it so we don't hang...
import tempfile
import traceback    # For exception logging if the servicelogger fails.
import runonce
import harshexit  # Used for portablekill
import portable_popen
from repyportability import *

import sys
import os
import os.path

# Used to import repy scripts without polluting the current directory.
import shutil
import tempfile

import repyhelper

repycachedir = tempfile.mkdtemp()

sys.path = [repycachedir] + sys.path
repyhelpercachedir = repyhelper.set_importcachedir(repycachedir)

repyhelper.translate_and_import("rsa.repy")
repyhelper.translate_and_import("signeddata.repy")
repyhelper.translate_and_import("time.repy")

shutil.rmtree(repycachedir)

# Armon: The port that should be used to update our time using NTP
TIME_PORT = 51345


def get_file_hash(filename):
    fileobj = file(filename, 'rb')
    filedata = fileobj.read()
    fileobj.close()
from repyportability import *

import sys
import os  
import os.path

# Used to import repy scripts without polluting the current directory.
import shutil
import tempfile

import repyhelper

repycachedir = tempfile.mkdtemp()

sys.path = [repycachedir] + sys.path
repyhelpercachedir = repyhelper.set_importcachedir(repycachedir)

repyhelper.translate_and_import("rsa.repy")
repyhelper.translate_and_import("signeddata.repy")
repyhelper.translate_and_import("time.repy")

shutil.rmtree(repycachedir)


# Armon: The port that should be used to update our time using NTP
TIME_PORT = 51345

def get_file_hash(filename):
  fileobj = file(filename, 'rb')
  filedata = fileobj.read()
  fileobj.close()
Beispiel #8
0
import repyhelper
import os
import sys
import resource
import time
if not os.path.exists('nodemanager.repyhelpercache'):
  os.mkdir('nodemanager.repyhelpercache')
sys.path = ['nodemanager.repyhelpercache'] + sys.path
repyhelpercachedir = repyhelper.set_importcachedir('nodemanager.repyhelpercache')
import warnings
warnings.simplefilter("ignore")
from repyportability import *

#repyhelper.translate_and_import("ShimStackInterface.repy")


CALLS = 100

def fun(n):
  shimstr = '(NoopShim)' * n
  #client = ShimStack(shimstr)
  sock = openconn('127.8.9.0', 12345)

  starttime = getruntime()
  for i in range(CALLS):
    sock.send('x')
  endtime = getruntime()
  
  sock.close()
  #DummyDNSStop()
"""
Test if bad calls to importcachedir are handled.

"""

import repyhelper



try:
  repyhelper.set_importcachedir(153)
except TypeError:
  pass
else:
  print "Was able to set the cache dir to be something besides a string..."


try:
  repyhelper.set_importcachedir('asdkfjaNONEXISTANT_DIRasfj')
except TypeError:
  pass
else:
  print "Was able to set my cache to a nonexistant dir..."


try:
  repyhelper.set_importcachedir('..')
except ValueError:
  pass
else:
  print "Was able to set my cache to be a dir that's not in the python path..."