Example #1
0
def find_sources(repo_name, directory_in_str):
    directory = os.fsencode(directory_in_str)
    response = []
    for file in os.listdir(directory):
        filename = os.fsdecode(file)
        if filename.endswith(".tf"):
            with open(directory_in_str + filename, "r") as f:
                searchfile = open(directory_in_str + filename, "r")
                # for line in searchfile:
                for num, line in enumerate(searchfile, 1):
                    if "source =" in line:

                        # print(directory_in_str+filename, num, line)
                        # print(num + ',' + line)
                        # based on what this returns we should be able to do our next check
                        # print(check_source_validity(line))
                        # we will now need to go get the source_version using get_repo_tags(repo)
                        for target_list in check_source_validity(line):
                            response1 = []
                            repo = target_list[0]
                            org = target_list[1]
                            current_version = target_list[2]
                            repo_tags = github_connect.get_repo_tags(repo +
                                                                     '/' + org)
                            response1.append(org)
                            response1.append(repo)
                            response1.append(repo_tags[0])
                            response1.append(current_version)
                            response1.append(filename)
                            response1.append(num)
                            response.append(response1)
                searchfile.close()
    helpers.parse_output(response, repo_name)
Example #2
0
def edp2sat(C, L):
    bits = int(math.ceil(math.log(2 * (C + 1), 2)))
    discrepancy = C
    length = L
    cmd = 'sat14 %d %d %d > out.cnf' % (length, discrepancy, bits)
    print "Compiling sat14.cc..."
    os.system('g++ sat14.cc -o sat14')
    print "Running sat14.cc..."
    os.system(cmd)
    print "Cleaning up the output..."
    os.system('grep -v "^c" out.cnf | grep -v "^$" > new.cnf')
    phi = h.parse_output('new.cnf')
    #print "Running the SAT solver..."
    return phi
def test_allocation():
    with helpers.set_single_system(True):
        result = helpers.parse_output('initial-install-config')
        nrc = NonRunningCommandRunner()
        overlay = gui.ControllerOverlay(None, nrc)
        class FakeStartKVM:
            def run(self):
                pass

        with mock.patch('cloudinstall.pegasus.StartKVM', FakeStartKVM):
            overlay.process(result)

        # we expect all the charms and relations to be added here
        assert len(nrc.to_run) == 14
Example #4
0
def edp2sat(C, L):
	bits = int(math.ceil(math.log(2*(C+1), 2)))
	discrepancy = C
	length = L
	cmd = 'sat14 %d %d %d > out.cnf' % (length, discrepancy, bits)
	print "Compiling sat14.cc..."
	os.system('g++ sat14.cc -o sat14')
	print "Running sat14.cc..."
	os.system(cmd)
	print "Cleaning up the output..."
	os.system('grep -v "^c" out.cnf | grep -v "^$" > new.cnf')
	phi = h.parse_output('new.cnf')
	#print "Running the SAT solver..."
	return phi
def test_parse_pending_lxcs():
    with helpers.set_single_system(True):
        result = helpers.parse_output('pending')
        assert len(result) == 7