Пример #1
0
def redis_status():
    message = ''
    if not cache.redis_conn:
        cache.init()
    if not cache.redis_conn:
        return {'redis': 'unconfigured'}
    key = toolkit.gen_random_string()
    value = toolkit.gen_random_string()
    try:
        cache.redis_conn.setex(key, 5, value)
        if value != cache.redis_conn.get(key):
            message = 'Set value is different from what was received'
    except Exception:
        message = str(sys.exc_info()[1])
    return {'redis': message}
Пример #2
0
def main():
    session = auth()
    cache.init()
    target = int(input("[?] Enter target's ID or handle: "))
    g = graph_algos.create_ego_graph(target, session)
    comm_list = graph_algos.get_communities(g, target, session=session)
    comm_dict = graph_algos.separate_communities(comm_list)
    sims = {"city": [], "country": [], "school": [], "university": []}
    for t in sims.keys():
        for comm in comm_dict.keys():
            sims[t].append((stats.find_similar(comm_dict[comm], session, t)))
        sims[t] = stats.calc_prob(sims[t])

    report.gen_report(str(target), sims)
    return 0
Пример #3
0
def entry():
  """
  Locate pusher.yaml in the current working directory and bootstrap a interactive deploy environment.
  """
  import yaml
  import json
  import ast

  opts = {
    "config": ["pusher.yaml", "pusher.json"]
  }

  import cache
  cache.init()

  try:
    getopts, args = getopt.gnu_getopt(sys.argv[1:], "c:l:D:")
  except getopt.GetoptError, e:
    print >> sys.stderr, "Option parsing failed: " + str(e)
    sys.exit(1)
Пример #4
0
import random
import string
import cache


def random_string(length):
    s = ''
    for i in range(length):
        s = s + random.choice(string.ascii_letters)
        return s


cache.init()

for n in range(1000):
    while True:
        key = random_string(20)
        if cache.contains(key):
            continue
        else:
            break
    value = random_string(20)
    cache.set(key, value)
    print("After {} iterations, cache has {} entries".format(n+1, cache.size()))
    print(key)


# test_cache.py

import random
import string
import cache

def random_string(length):
    s = ''
    for i in range(length):
        s = s + random.choice(string.ascii_letters)
    return s

cache.init()

for n in range(1000):
    while True:
        key = random_string(20)
        if cache.contains(key):
            continue
        else:
            break
    value = random_string(20)
    cache.set(key, value)
    print("After {} iterations, cache has {} entries".format(n+1, cache.size()))

Пример #6
0
    if args.auth_user:
        AUTH_USER = args.auth_user
    if args.auth_pass:
        AUTH_PASS = args.auth_pass
    if args.include_auth_user:
        INCLUDE_AUTH_USER = True
    if args.ingester is not None:
        INGESTER_PATH = args.ingester
    if args.ingester_off:
        INGESTER_PATH = None
    if args.limit is not None:
        LIMIT = args.limit
    if args.username:
        USERNAME = args.username
    if args.retries is not None:
        REQUEST_RETRIES = args.retries
    if args.timeout is not None:
        REQUEST_TIMEOUT = args.timeout
    if args.cache_on:
        CACHE_ENABLED = True
    if args.cache_off:
        CACHE_ENABLED = False
    if args.verbose:
        VERBOSE = True


_load()
_parse_args()
_init_logging()
cache.init(CACHE_PATH, CACHE_ENABLED, CACHE_SECONDS)
Пример #7
0
images.init() #On charge toutes les textures du jeu

joueur.init() #On initialise le joueur...
monstres.init()#...les monstres...
boulesdefeu.init()#... et les boules de feu.
bonus.init()

niveaux = ["tutoriel", "niveau1", "niveau2", "niveau3", "fin du jeu"]#Liste des niveaux
niveauActuel = 0 #Niveau dans lequel le joueur se trouve actuellement

interface.init() #Initialisation de l'interface (compteurs de bonus)

carte.init(niveaux[niveauActuel],True) #On charge le terrain du jeu depuis un fichier

cache.init(largeur,hauteur,niveaux[niveauActuel])
#On initialise la camera, la centrant sur le joueur et lui mettant les dimensions de la fenêtre:
camera.init(joueur.x,joueur.y,largeur,hauteur,carte.w*32,carte.h*32)

#On initialise l' "afficheur", qui permettra le rendu des textures à l'écran
afficheur.init(0,0)
afficheur.mettreWindow(window)
afficheur.update(camera.x, camera.y)

musiquelancee = False
end = False

def reinitialiserNiveau():#Permet de réinitialiser tout sauf l'état de la carte
    joueur.init()
    monstres.init()
    boulesdefeu.init()
Пример #8
0
def runTestCases(caseList):
  t0 = time.time()
  
  logPath = env.getValue('logPath')
  if logPath is None:
    logPath = '.'

  logName = env.getValue('logName')
  if logName:
    logName = os.path.join(logPath, logName)
  else:
    logName = os.path.join(logPath, '%s_%s' % (misc.testSuiteName, misc.getTimeStr()))

  if not misc.makeDirs(logName):
    return

  misc.removeFile(logName + '.txt')
  log.open(logName + '.txt', log = 'suite', enableConsole = False)

  nodeList = env.getNodeList(10000, respectLimit = True) # Get as many as we can
  nodesAvail = len(nodeList)

  nodes.setStatus(nodeList, '%s: preparing' % misc.testSuiteName)

  result = {True: 0, False: 0}

  # Extract all required info from cases and build all images
  extList = expandCaseList(caseList, nodesAvail)
  cache.init()
  
  t1 = time.time()
#  buildImagesForTestSuite(extList)
  buildTime = time.time() - t1
  cache.sync()

  # Remove cases without all required images built
  workList = []
  fullSet = []
  for caseName, connParameters, variables in extList:
    workList += [(caseName, connParameters, variables)]
    fullSet = misc.clists([fullSet, [par for conn, par in connParameters.iteritems()]])

  nodesNeeded = len(fullSet)

  if nodesAvail < nodesNeeded:
    log.write('Info: for maximum performance %d nodes required (%d nodes available)' %
      (nodesNeeded, nodesAvail), log = 'suite')
  else:
    log.write('Info: %d nodes will be used' % nodesNeeded, log = 'suite')
    nodesAvail = nodesNeeded
  
  # Group all scripts to optimize upload strategy
  groups = groupCases(workList, nodesAvail)
  log.write('Info: %d uploads will be performed' % len(groups), log = 'suite')
  
  
  # Upload and execute scripts
  nodeList = nodeList[:nodesAvail]
  allNodes = []
  log.write('Test will use next nodes:', log = 'suite')
  for node in nodeList:
    log.write('  %s' % node, log = 'suite')
    allNodes += [misc.__nodeFactory.create(node)]

  #for node in allNodes:
  #  node.getConnection().setTesterMode(misc.runOn['tester'])

  testCaseExecTimes = []
  uploadTimes = []
  nodes.restart(allNodes, leaveOff = True)
  groupNo = 1

  for group in groups:
    log.write('Running group %d of %d' % (groupNo, len(groups)), log = 'suite')
    t2 = time.time()
    usedNodes = uploadNodesFromGroup(allNodes, workList, group)
    uploadTimes.append(time.time() - t2)
    time.sleep(1)
    for index in group:
      t3 = time.time()
      ret = runCaseFromGroup(workList[index], usedNodes, logName)
      testCaseExecTimes.append(time.time() - t3)
      result[ret] += 1
    groupNo += 1

  if len(uploadTimes):
    meanUploadTime = sum(uploadTimes) / len(uploadTimes)
  else:
    meanUploadTime = 0

  if len(testCaseExecTimes):
    meanTestcaseExecTime = sum(testCaseExecTimes) / len(testCaseExecTimes)
  else:
    meanTestcaseExecTime = 0

  totalTime = time.time() - t0
  
  log.write('Test finished: %d passed, %d failed' % (result[True], result[False]), log = 'suite')
  log.write('Execution time statistics', log = 'suite')
  log.write('Build images time: %d sec' % buildTime, log = 'suite')
  log.write('Total upload time: %d sec' % sum(uploadTimes), log = 'suite')
  log.write('Mean group upload time: %d sec' % meanUploadTime, log = 'suite')
  log.write('Testcases execution time: %d sec' % sum(testCaseExecTimes), log = 'suite')
  log.write('Mean testcase execution time: %d sec' % meanTestcaseExecTime, log = 'suite')
  log.write('Total execution time: %d sec' % totalTime, log = 'suite')

  # Remove all temporary files, save cache
  cache.cleanup()