def MsWave( k, query, sites, pivot): cost = 0 qcost = 0 rt = root(k, query, pivot) for site in sites.values(): levelq, s, e, qssum, k = rt.send_first(site.siteid) ub = site.cp_first(levelq, s, e, qssum, k) rt.cp1(ub) cost += levelq.size + 1 + len(qssum)+ len(ub) qcost += levelq.size for site in sites.values(): th = rt.cp2() rc = site.prune(th) rt.check1(site.siteid,rc) cost += 2 rt.check2() level_rs = [] while( not rt.isdone() ): rs = rt.remainsite() level_rs += [len(rs)] #print len(rs) for site in sites.values(): if site.siteid not in rs: continue levelq, s, e = rt.send_later(site.siteid) ub = site.cp_later(levelq, s, e) rt.cp1(ub) cost += levelq.size + len(ub) qcost += levelq.size for site in sites.values(): if site.siteid not in rs: continue th = rt.cp2() rc = site.prune(th) rt.check1(site.siteid,rc) cost += 2 rt.check2() rs = rt.remainsite() level_rs += [len(rs)] ans = [] for site in sites.values(): if site.siteid not in rs: continue ans += site.get_ans() cost += len(ans) return ans, cost, level_rs, qcost
def __init__(self, base, selfURIs, encoding): from root import root ContentHandler.__init__(self) self.lastKnownLine = 1 self.lastKnownColumn = 0 self.loggedEvents = [] self.feedType = 0 self.xmlBase = base self.selfURIs = selfURIs self.encoding = encoding self.handler_stack = [[root(self, base)]] validatorBase.defaultNamespaces = []
def __init__(self, base, selfURIs, encoding): from root import root ContentHandler.__init__(self) self.lastKnownLine = 1 self.lastKnownColumn = 0 self.loggedEvents = [] self.feedType = 0 try: self.xmlBase = base.encode('idna') except: self.xmlBase = base self.selfURIs = selfURIs self.encoding = encoding self.handler_stack=[[root(self, base)]] validatorBase.defaultNamespaces = []
def upload_recipes(remote, remote_dir="/etc/puppet/modules/"): recipes_dir = root('deployment', 'puppet') tar_file = None try: if EXIST_TAR: remote.upload(EXIST_TAR, '/tmp/recipes.tar') else: tar_file = remote.open('/tmp/recipes.tar', 'wb') with tarfile.open(fileobj=tar_file, mode='w') as tar: tar.add(recipes_dir, arcname='') remote.mkdir(remote_dir) remote.check_call('tar -xf /tmp/recipes.tar -C %s' % remote_dir) finally: if tar_file: tar_file.close()
def __init__(self, base, selfURIs, encoding): from root import root ContentHandler.__init__(self) self.lastKnownLine = 1 self.lastKnownColumn = 0 self.loggedEvents = [] self.feedType = 0 try: self.xmlBase = base.encode('idna') except: self.xmlBase = base self.selfURIs = selfURIs self.encoding = encoding self.handler_stack = [[root(self, base)]] self.literal_entities = [] self.defaultNamespaces = []
def upload_recipes(remote, remote_dir="/etc/puppet/modules/"): recipes_dir = root('deployment', 'puppet') tar_file = None try: if EXIST_TAR: remote.upload(EXIST_TAR, '/tmp/recipes.tar') else: tar_file = remote.open('/tmp/recipes.tar', 'wb') with tarfile.open(fileobj=tar_file, mode='w', dereference=True) as tar: tar.add(recipes_dir, arcname='') remote.mkdir(remote_dir) remote.check_call('tar xmf /tmp/recipes.tar --overwrite -C %s' % remote_dir) finally: if tar_file: tar_file.close()
def setup(self): self.game_over = False self.energy = ENERGY_MAX self.level = 3 self.generator = terrainGenerator.terrainGenerator() self.initialTerrain() self.decals = [] self.decals.append(decal(PLANT,0,(RES_X//100)*50-18,150,100)) self.decals.append(decal(CLOUD1,5,15,90,199)) self.decals.append(decal(CLOUD2,7,870,87,201)) self.decals.append(decal(CLOUD3,4,400,58,104)) self.decals.append(decal(CLOUD4,10,1200,50,82)) self.roots = [] self.roots.append(root.root(self,(3,RES_X//100),DOWN)) self._if.score() self._if.handlemusic()
def __init__(self, base, selfURIs, encoding): from root import root ContentHandler.__init__(self) self.lastKnownLine = 1 self.lastKnownColumn = 0 self.loggedEvents = [] self.feedType = 0 try: self.xmlBase = base.encode('idna') except: self.xmlBase = base self.selfURIs = selfURIs self.encoding = encoding self.handler_stack = [[root(self, base)]] self.defaultNamespaces = [] # experimental RSS-Profile support self.rssCharData = []
def __init__(self, base, selfURIs, encoding): from root import root ContentHandler.__init__(self) self.lastKnownLine = 1 self.lastKnownColumn = 0 self.loggedEvents = [] self.feedType = 0 try: self.xmlBase = base.encode('idna') except: self.xmlBase = base self.selfURIs = selfURIs self.encoding = encoding self.handler_stack=[[root(self, base)]] self.defaultNamespaces = [] # experimental RSS-Profile support self.rssCharData = []
def send(): li = [] print("give the range in which you want prime numbers") print("start=", end=" ") lower = int(input()) print("last=", end=" ") print("should no exceed 1024", end=" ") upper = int(input()) print("prime between", lower, "and", upper, "are:") for num in range(lower, upper): if (prime.isprime(num)): print(num, end=" ") li.append(num) print() print("select a prime", end=" ") q = int(input()) if q not in li: f1 = 1 while (f1): if q not in li: print("please select the prime number from below list only") print(li) q = int(input()) if q in li: f1 = 0 print("primitive roots list") li = [] print("enter lower and upper limits of primitive roots") print("upper limit should not execeed " + str(q)) lower = int(input()) upper = int(input()) print("k") for k in range(lower, upper): c = root.root(k, q) if (c is not 0): print(c, end=" ") li.append(c) print() print("selct root ", end=" ") a = int(input()) if a not in li: f1 = 1 while (f1): if a not in li: print("please select the root from below list only") print(li) a = int(input()) if a in li: f1 = 0 print("Aggreed prime is", q, "and root is", a) print("enter a secret value of the alice", end=" ") pia = int(input()) if pia not in range(1, q): f1 = 1 while (f1): if pia not in range(1, q): print("please select in range", 1, "and", q) pia = int(input()) if pia in range(1, q): f1 = 0 pua = key.kg(pia, a, q) print() print("public of alice", pua) return q, a, pua
while (f1): if q not in li: print("please select the prime number from below list only") print(li) q = int(input()) if q in li: f1 = 0 print("primitive roots list") li = [] print("enter lower and upper limits of primitive roots") print("upper limit should not execeed " + str(q)) lower = int(input()) upper = int(input()) print("k") for k in range(lower, upper): c = root.root(k, q) if (c is not 0): print(c, end=" ") li.append(c) print() print("selct root ", end=" ") a = int(input()) if a not in li: f1 = 1 while (f1): if a not in li: print("please select the root from below list only") print(li) a = int(input()) if a in li: f1 = 0
def install_astute(remote): remote.upload( root('deployment', 'mcollective', 'astute', 'astute-0.0.1.gem'), '/tmp/astute-0.0.1.gem') remote.check_stderr('gem install /tmp/astute-0.0.1.gem')
def build_astute(): subprocess.check_output(['gem', 'build', 'astute.gemspec'], cwd=root('deployment', 'mcollective', 'astute'))
def upload_keys(remote, remote_dir="/var/lib/puppet/"): ssh_keys_dir = root('fuel_test', 'config', 'ssh_keys') remote.upload(ssh_keys_dir, remote_dir)
import os.path import sys import logging import argparse from nose.plugins.manager import PluginManager from nose.plugins.xunit import Xunit from root import root, REPOSITORY_ROOT sys.path[:0] = [ REPOSITORY_ROOT, root('devops'), ] import fuelweb_test.integration def main(): parser = argparse.ArgumentParser(description="Integration test suite") parser.add_argument("-i", "--iso", dest="iso", help="iso image path or http://url") parser.add_argument("-l", "--level", dest="log_level", type=str, help="log level", choices=["DEBUG", "INFO", "WARNING", "ERROR"], default="ERROR", metavar="LEVEL") parser.add_argument('--no-forward-network',
def menu(): print("1-Addition \t\t 2-Subtration \t\t 3-Multiply \t\t 4-Division") print("5-Sin() \t\t 6-Cos() \t\t 7-Tan() \t\t 8-Sec()") print("9-Cosec() \t\t 10-Cot() \t\t 11-Square \t\t 12-Square Root \t\t") print("13-Power \t\t 14-Root \t\t 15-Expontial(e^x)") print("16-Factorial \t\t 17-log()\t\t 18-ln() \t\t 19-Quadratic Eq Solver") print( "20-Inverse(x^-1) \t 21-Sin inverse \t 22-Cos Inverse \t 23.Tan Inverse" ) print("24-Permutation \t\t 25-Combination \t 26-Percentage") print("27-Multiple Basic Operators At a time \t\t 28-Close") while True: try: choice = int(input("Enter your choice(press number):")) break except ValueError: print("Input must be a number!") if choice == 1: while True: Sum.Sum() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 2: while True: Sub.sub() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 3: while True: Mul.multiply() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 4: while True: divide.divide() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 5: while True: sin.sin() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 6: while True: cos.cos() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 7: while True: tan.tan() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 8: while True: sec.sec() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 9: while True: cosec.cosec() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 10: while True: cot.cot() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 11: while True: square.square() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 12: while True: sqrt.sqrt() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 13: while True: power.power() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 14: while True: root.root() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 15: while True: exponential.exponential() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 16: while True: factorial.factorial() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 17: while True: log.log() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 18: while True: ln.ln() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 19: while True: quadratic.quadratic() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 20: while True: inverse.inv() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 21: while True: asin.asin() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 22: while True: acos.acos() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 23: while True: atan.atan() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 24: while True: per.per() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 25: while True: com.com() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 26: while True: percentage.percentage() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 27: while True: combine() x = int(input("press 1 to try again,press 2 to return to menu")) if x == 1: continue if x == 2: menu() break elif choice == 28: close() else: print("Invalid Input.Try Again") menu()
def test_root(self): self.assertAlmostEqual(root(4),2)
def build_astute(): subprocess.check_output( ['gem', 'build', 'astute.gemspec'], cwd=root('deployment', 'mcollective', 'astute'))
def formula(num1, num2): res = div.division(pow.power(num1)+sqrt.root(pow.power(pow.power(num2)-mod.module(num1)+5*num1*num2)),sqrt.root(pow.powe(pow.power(num1)-mod.module(num2)+5*num2*num1))-5) return res
import sys import traceback from root import root from sysException import sysException # Data path path = '備審資料' # Test path # path = '備審資料/106生醫/10117018' try: if __name__ == '__main__': # 1: use layout.txt setting to get score and append excel # 2: print pdf score page data # 3: test pdf setting with layout.txt print("--------------------------------------------------------------") root(path,1) print("--------------------------------------------------------------") # root(path,2) print("--------------------------------------------------------------") # root(path,3) print("--------------------------------------------------------------") except Exception as e: print(sysException(e))
import os.path import sys import logging import argparse from nose.plugins.manager import PluginManager from nose.plugins.xunit import Xunit from root import root, REPOSITORY_ROOT sys.path[:0] = [ REPOSITORY_ROOT, root('devops'), ] import fuelweb_test.integration def main(): parser = argparse.ArgumentParser(description="Integration test suite") parser.add_argument("-i", "--iso", dest="iso", help="iso image path or http://url") parser.add_argument("-l", "--level", dest="log_level", type=str, help="log level", choices=[ "DEBUG", "INFO", "WARNING", "ERROR" ], default="ERROR", metavar="LEVEL") parser.add_argument('--no-forward-network', dest='no_forward_network', action="store_true", default=False,
def test_jokes(self): joke = asyncio.get_event_loop().run_until_complete( root('сая скажи шутку')) print("Joke:", joke) assert joke is not None, 'get joke'