Ejemplo n.º 1
0
def normalizer(this, tothis):
    your_path = input("Path? :")
    files = os.listdir(your_path)
    print(files)
    for file in files:
        pyutil.filereplace(os.path.join(your_path, file), this, tothis)
        print(os.path.join(your_path, file) + '  ✓')
Ejemplo n.º 2
0
def spellCheck():
    if (request.method == 'POST'):
        print(request.form['file_name'])
        with open(request.form['file_name'], 'r+') as file:
            for line in file:
                for word in line.split():
                    crr = TextBlob(word)
                    print(str(crr.correct()))
                    filereplace("missepelled.txt", word, str(crr.correct()))

    notify.send("Hey all checked!, check your file")

    return redirect('/')
Ejemplo n.º 3
0
def sshd_config_mgr():

    user_req = input(
        "\nWelcome to sshd_config manager:\n   [1] Operational Config\n   [2] Config Change\n    >:"
    )
    if user_req == '1':
        with open('sshd_config', 'r') as openfile:
            for line in openfile:
                print(line)
    elif user_req == '2':
        oper_conf = input("\nEnter your operational config:\t")
        user_conf = input("Enter your new config:\t")
        filereplace('sshd_config', oper_conf, user_conf)
        os.system('sudo systemctl restart sshd')
    else:
        print("Invalid Input")
Ejemplo n.º 4
0
def update_pkgbuild(remote_version, local_version):
    filereplace("./PKGBUILD", local_version, remote_version)
    child = pexpect.spawnu('makepkg -g')
    child.expect(r'md5sums=\(\'([a-fA-F\d]*)\'\)')
    file_hash = child.match.group(0)
    filereplace('./PKGBUILD', r'md5sums=\(\'([a-fA-F\d]*)\'\)', file_hash)
    child = pexpect.spawn('/bin/bash -c "makepkg --printsrcinfo > .SRCINFO"')
    child.expect(pexpect.EOF)
    child = pexpect.spawnu('git add .SRCINFO PKGBUILD')
    child.expect(pexpect.EOF)
    child = pexpect.spawnu(
        'git commit -m "Updated screen-desktop to version {remote_version}"'.
        format(remote_version=remote_version))
    child.expect(pexpect.EOF)
    child = pexpect.spawnu('git push origin master')
    child.expect(r'Enter passphrase for key .*')
    child.sendline(os.getenv("PW"))
    child.expect(pexpect.EOF)
    def edit_message_logging(current_path, proxy_name_include_ml, name_ml,
                             token, message_log, host, port):
        file_message_logging = open(
            current_path + "\\proxies" + "\\" + proxy_name_include_ml +
            "\\apiproxy\\policies" + "\\" + name_ml + ".xml", 'r')
        lines = file_message_logging.readlines()
        for line in lines:
            #print(line)
            matches_message_ml = re.match(r'\s*<Message>(.*?)</Message>', line)
            if matches_message_ml:
                message_ml = matches_message_ml.group(1)
            matches_host_ml = re.match(r'\s*<Host>(.*?)</Host>', line)
            if matches_host_ml:
                host_ml = matches_host_ml.group(1)
            matches_port_ml = re.match(r'\s*<Port>(.*?)</Port>', line)
            if matches_port_ml:
                port_ml = matches_port_ml.group(1)

        file_message_logging.close()

        pyutil.filereplace(
            current_path + "\\proxies" + "\\" + proxy_name_include_ml +
            "\\apiproxy\\policies\\" + name_ml + ".xml",
            "<Message>" + message_ml + "</Message>",
            "<Message>" + message_log + "</Message>")
        pyutil.filereplace(
            current_path + "\\proxies" + "\\" + proxy_name_include_ml +
            "\\apiproxy\\policies\\" + name_ml + ".xml",
            "<Host>" + host_ml + "</Host>", "<Host>" + host + "</Host>")
        pyutil.filereplace(
            current_path + "\\proxies" + "\\" + proxy_name_include_ml +
            "\\apiproxy\\policies\\" + name_ml + ".xml",
            "<Port>" + port_ml + "</Port>", "<Port>" + port + "</Port>")
Ejemplo n.º 6
0
    if pat:
        count_sf = count_sf + 1
print(
    "--------------------------------------------------------------------------"
)
print("|                      Total sharedflows " + str(count_sf) +
      "    	        		 |")
print(
    "--------------------------------------------------------------------------"
)

print(
    "--------------------------------------------------------------------------"
)
print("|                      Total Environments  " +
      str(int(((count + count_sf) / 50) + 1)) + "       		         |")
print(
    "--------------------------------------------------------------------------"
)

req_evn = int(((count + count_sf) / 50) + 1)
evn = []
for i in range(0, req_evn):
    evn.append("test" + str(i))
print(str(evn))
evn = str(evn)
evn = evn.replace('\'', '\"')

############# Update Config.json File ####################
pyutil.filereplace("config.json", '\\[.*\\]', evn)
Ejemplo n.º 7
0
    def update_kvm_using_policy(current_path, src_kvm_file):
        try:
            proxies_folder_path = current_path + "\\proxies"
            os.chdir(proxies_folder_path)
            filenames = ['create_kvm_values_demo.zip']
            filename = "create_kvm_values_demo"
            zip_n_unzip.Unzip.unzip_file(
                filename, current_path + "\\proxies" + "\\" + filename)
            kvm_names = os.listdir(current_path + "\\kvm\\env\\test")
            #print(kvm_names)
            print("------------------------------------------------------")
            print("|  Total KVM,s " + str(len(kvm_names)))
            print("------------------------------------------------------")
            print("------------------------------------------------------")
            print("| Copying the required KVM DUMMY  policy file     |")
            print("------------------------------------------------------")
            dest_kvm_dir = current_path + "\\proxies" + "\\" + filename + "\\apiproxy\\policies"
            shutil.copy(src_kvm_file, dest_kvm_dir)
            print("------------------------------------------------------")
            print("|                   Copied                           |")
            print("------------------------------------------------------")

            tota_kvm = len(kvm_names)
            list_of_kvm_values = []
            q = ''
            count = 0
            steps_variable = ""
            policy_variable = ''
            manifest_variable = ''

            for kvm_name in kvm_names:
                with open(current_path + '\\kvm\\env\\test\\' +
                          kvm_name) as json_data_file:
                    data = json.load(json_data_file)
                    json_data_file.close()

                print("KVM MAP IDENTIFIER " + kvm_name)
                os.rename(
                    current_path + "\\proxies" + "\\" + filename +
                    "\\apiproxy\\policies\\KVM.xml",
                    current_path + "\\proxies" +
                    "\\create_kvm_values_demo\\apiproxy\\policies\\kvm_" +
                    kvm_name + ".xml")
                print("------------------------------------------------------")
                print("|                 Renamed                            |")
                print("------------------------------------------------------")

                ################################ Replacing Variable inside the KVM File ############################################
                pyutil.filereplace(
                    current_path + "\\proxies" + "\\" + filename +
                    "\\apiproxy\\policies\\kvm_" + kvm_name + '.xml',
                    'mapIdentifier="Basic-Auth"',
                    'mapIdentifier="' + kvm_name + '"')
                pyutil.filereplace(
                    current_path + "\\proxies" + "\\" + filename +
                    "\\apiproxy\\policies\\kvm_" + kvm_name + '.xml',
                    'name="KVM_dummy"', 'name="kvm_' + kvm_name + '"')
                pyutil.filereplace(
                    current_path + "\\proxies" + "\\" + filename +
                    "\\apiproxy\\policies\\kvm_" + kvm_name + '.xml',
                    '<DisplayName>KVM</DisplayName>',
                    '<DisplayName>kvm_' + kvm_name + '</DisplayName>')

                q = q + data['name'] + "," + str(data['encrypted']) + ","
                list_of_kvm_values.append(data['name'])
                list_of_kvm_values.append(data['encrypted'])

                values = data['entry']
                for value in values:
                    list_of_kvm_values.append(value['name'])
                    list_of_kvm_values.append(value['value'])

                    q = q + "|*  [" + value['name'] + "],[" + value[
                        'value'] + "]  *| "
                q = q + "\n"
                #print(q)
                matches_key_val = re.search(r'' + kvm_name + '.*\\[(.*?)\\]',
                                            q)
                if matches_key_val:
                    key_values = matches_key_val.group(0)
                    splited_values = key_values.split("|*")
                    #print(len(splited_values))
                    length_of_kv = len(splited_values)
                    add_multiple_kv = ''
                    for kvm in range(0, length_of_kv):
                        if kvm == 0:
                            continue
                        #print(splited_values[kvm])
                        extract_key_values = re.search(r'\[(.*?)\]\,\[(.*?)\]',
                                                       splited_values[kvm])
                        if extract_key_values:
                            print("Keys ====>" + extract_key_values.group(1))
                            indivi_key = extract_key_values.group(1)
                            print("Values  ====>" +
                                  extract_key_values.group(2))
                            indivi_value = extract_key_values.group(2)
                            add_multiple_kv = add_multiple_kv + "<Key><Parameter>" + indivi_key + "</Parameter></Key><Value>" + indivi_value + "</Value>"
                            #print(add_multiple_kv)
                    pyutil.filereplace(
                        current_path + "\\proxies" +
                        "\\create_kvm_values_demo\\apiproxy\\policies\\kvm_" +
                        kvm_name + '.xml',
                        '<Key>\\s*<Parameter>password2\\s*</Parameter>\\s*</Key>\\s*<Value>justsecret\\s*</Value>',
                        add_multiple_kv)

                print("------------------------------------------------------")
                print("| Copying the required KVM DUMMY policy file         |")
                print("------------------------------------------------------")
                dest_kvm_dir = current_path + "\\proxies" + "\\" + filename + "\\apiproxy\\policies"
                shutil.copy(src_kvm_file, dest_kvm_dir)
                print("------------------------------------------------------")
                print("|                   Copied                           |")
                print("------------------------------------------------------")
                steps_variable = steps_variable + "<Step><Name>kvm_" + kvm_name + "</Name></Step>"
                policy_variable = policy_variable + " <Policy>kvm_" + kvm_name + "</Policy>"
                manifest_variable = manifest_variable + "<VersionInfo resourceName= 'kvm_" + kvm_name + "' version='SHA-512:3875e5b9dad448c08921966e7bdc459cb19b774ee9701700821365d330d551e5b7639817879cb31ad7853165e3b60707d05f3b4d0ee2028cc005e940c4700556'/>"
                #print(q)
            #print(steps_variable)
            ############################################ Replacing Steps in default xml ################################################
            pyutil.filereplace(
                current_path + "\\proxies" + "\\" + filename +
                "\\apiproxy\\proxies\\default.xml",
                '\\s*<Step>\\s*<Name>\\s*KVM_DUMMY\\s*</Name>\\s*</Step>',
                '<Step><Name>KVM_DUMMY</Name></Step>' + steps_variable)

            ############################################ Replacing Policies in Root Folder ################################################
            pyutil.filereplace(
                current_path + "\\proxies" + "\\" + filename +
                "\\apiproxy\\create_kvm_values.xml",
                '\\s*<Policy>KVM_DUMMY</Policy>',
                '<Policy>KVM_DUMMY</Policy>' + policy_variable)

            ############################################ Replacing Policies in Manifest File ################################################
            pyutil.filereplace(
                current_path + "\\proxies" + "\\" + filename +
                "\\apiproxy\\manifests\\manifest.xml",
                '\\s*<VersionInfo\\s*resourceName="KVM_DUMMY"\\s*version="SHA-512:3875e5b9dad448c08921966e7bdc459cb19b774ee9701700821365d330d551e5b7639817879cb31ad7853165e3b60707d05f3b4d0ee2028cc005e940c4700556"/>',
                '<VersionInfo resourceName="KVM_DUMMY" version="SHA-512:3875e5b9dad448c08921966e7bdc459cb19b774ee9701700821365d330d551e5b7639817879cb31ad7853165e3b60707d05f3b4d0ee2028cc005e940c4700556"/>'
                + manifest_variable)

            ######################################### Disable the DUMMY Policy ###############################################################
            pyutil.filereplace(
                current_path + "\\proxies" + "\\" + filename +
                "\\apiproxy\\policies\\KVM_DUMMY.xml", 'enabled="true"',
                'enabled="false"')

            resource_type = "apis"
            resource_id = "apiProxyId"
            zip_n_unzip.Zip.create_newzip_after_changes(
                "create_kvm_values_demo", current_path + "\\proxies")
            print(
                "Deploy and run create_kvm_values_demo  proxy to update all KVM values"
            )

        except OSError as e:
            print(e.strerror)
            print(
                " create_kvm_values_demo.zip file is not found in the DATA Folder COPY the zip and try again "
            )
    def edit_static_collector(path, filename, token):
        #dc_var_name=""

        file_to_delete = ""
        src_file = 'C:\\Users\\SANTOSH\\Desktop\\DataCapture.xml'
        dest_dir = path + "\\" + filename + "\\apiproxy\\policies"
        os.chdir(path + "\\" + filename + "\\apiproxy\\policies")
        arr = os.listdir()
        policy_name = ''
        policy_display_name = ''
        assigned_var = ''
        referenced_var = ''
        type_var = ''
        for i in arr:
            print(i)
            file2 = open(path + "\\" + filename + "\\apiproxy\\policies\\" + i,
                         'r')
            lines = file2.readlines()
            for line in lines:
                pattern = '<StatisticsCollector'
                result = re.match(pattern, line)
                if result:
                    print(
                        "StatisticsCollector policy found and needs to be removed"
                    )
                    print("Current File Name " + i)
                    file_to_delete = i
                    print("File to delete " + file_to_delete)
                    print(
                        "Copying the required  Statistic Collector policy file"
                    )
                    shutil.copy(src_file, dest_dir)
                    print("Copied")
                match_name = re.search(r'<StatisticsCollector.*name="(.*?)"',
                                       line)
                if match_name:
                    policy_name = match_name.group(1)
                match_display_name = re.search(
                    r'<DisplayName>(.*?)</DisplayName>', line)
                if match_display_name:
                    policy_display_name = match_display_name.group(1)
                match_variables = re.search(
                    r'<Statistic name="(.*?)" ref="(.*?)" type="(.*?)"', line)
                if match_variables:
                    assigned_var = match_variables.group(1)
                    referenced_var = match_variables.group(2)
                    type_var = match_variables.group(3)
                match_default_value = re.search(
                    r'<Statistic .*>(.*?)</Statistic', line)
                if match_default_value:
                    default_value_stats = match_default_value.group(1).strip()
                else:
                    default_value_stats = "0"
            file2.close()
        print("Deleting " + file_to_delete + " policy file")
        os.remove(path + "\\" + filename + "\\apiproxy\\policies\\" +
                  file_to_delete)
        print("Successfully deleted StatisticsCollector policy ")
        match_dc_file_name = ''
        os.chdir(path + "\\" + filename + "\\apiproxy\\policies")
        arr = os.listdir()
        for i in arr:
            file3 = open(path + "\\" + filename + "\\apiproxy\\policies\\" + i,
                         'r')
            lines = file3.readlines()
            for line in lines:
                #print(line)
                pattern = '<DataCapture'
                result = re.match(pattern, line)
                if result:
                    print("DataCapture policy found")
                    match_dc_file_name = re.search(
                        r'DataCapture.*name="(.*?)"', line)
                    if match_dc_file_name:
                        m_dc_file_name = match_dc_file_name.group(1)
                match_dc_var_name = re.search(
                    r'<DataCollector>(.*?)</DataCollector>', line)
                if match_dc_var_name:
                    dc_var_name = match_dc_var_name.group(1)
                    print("DATA COLLECTOR VALUE : " +
                          match_dc_var_name.group(1))
                    dc_store_obj = Dc_store
                    dc_store_obj.dc_store(token, dc_var_name)

            file3.close()
        print(
            "Changing values inside the DataCapture policy to match with the Statistic Collector Policy"
        )
        pyutil.filereplace(
            path + "\\" + filename + "\\apiproxy\\policies\\" +
            m_dc_file_name + '.xml', '<DataCapture name="DataCapture"',
            '<DataCapture name="' + policy_name + '"')
        pyutil.filereplace(
            path + "\\" + filename + "\\apiproxy\\policies\\" +
            m_dc_file_name + '.xml',
            ' <DisplayName>DataCapturepolicy</DisplayName>',
            ' <DisplayName>' + policy_display_name + '</DisplayName>')
        if default_value_stats == 0:
            pyutil.filereplace(
                path + "\\" + filename + "\\apiproxy\\policies\\" +
                m_dc_file_name + '.xml',
                '<Collect ref="existing-variable" default="0"/>',
                '<Collect ref="' + referenced_var + '" default="0"/>')
        else:
            pyutil.filereplace(
                path + "\\" + filename + "\\apiproxy\\policies\\" +
                m_dc_file_name + '.xml',
                '<Collect ref="existing-variable" default="0"/>',
                '<Collect ref="' + referenced_var + '" default="' +
                default_value_stats + '"/>')
            print("Changes Applied")
        print(
            "Renaming the DataCapture Policy to match with Statistic Collector policy"
        )
        os.rename(
            path + "\\" + filename + "\\apiproxy\\policies\\" +
            m_dc_file_name + '.xml',
            path + "\\" + filename + "\\apiproxy\\policies\\" + file_to_delete)
        print("Renamed")
Ejemplo n.º 9
0
trgfile = "./var/backup/mariadb2.dump"


# get file encoding type
def get_encoding_type(file):
    with open(file, 'rb') as f:
        rawdata = f.read()
    return detect(rawdata)['encoding']


from_codec = get_encoding_type(srcfile)

# add try: except block for reliability
try:
    with open(srcfile,
              'r', encoding=from_codec) as f, open(trgfile,
                                                   'w',
                                                   encoding='utf-8') as e:
        text = f.read()  # for small files, for big use chunks
        e.write(text)

    os.remove(srcfile)  # remove old encoding file
    os.rename(trgfile, srcfile)  # rename new encoding
except UnicodeDecodeError:
    print('Decode Error')
except UnicodeEncodeError:
    print('Encode Error')

# replace charset latin1 to ut8
filereplace(srcfile, "CHARSET=latin1",
            "CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci")
    def edit_spike_arrest(current_path, proxy_name_include_sa, name_sa, token,
                          no_of_mp):

        ref_var = ''
        value_of_effective_count = 'false'
        file_spike_arrest = open(
            current_path + "\\proxies" + "\\" + proxy_name_include_sa +
            "\\apiproxy\\policies" + "\\" + name_sa + ".xml", 'r')
        lines = file_spike_arrest.readlines()
        for line in lines:
            #print(line)
            match_spike_1 = re.search(r'<Rate ref="(.*?)"/>', line)
            if match_spike_1:
                ref_var = match_spike_1.group(1)
                #print("Reference variable value is ====>"+ref_var)

            match_spike_2 = re.search(r"<Rate>(.*?)</Rate>", line)
            if match_spike_2:
                #print(match_spike_2.group(1))
                original_spike_rate = match_spike_2.group(1)
                match_only_digit = re.search(r"(.*?)p", original_spike_rate)
                if match_only_digit:
                    #print(match_only_digit.group(1))
                    only_digit = match_only_digit.group(1)
                match_unit = re.search(r"p(.*)", original_spike_rate)
                if match_unit:
                    #print(match_unit.group(1))
                    unit_spike = match_unit.group(1)
            matches_true = re.search(
                r"\s*<UseEffectiveCount>(.*?)</UseEffectiveCount>", line)
            if (matches_true):

                value_of_effective_count = matches_true.group(1)
                #print(value_of_effective_count)
                #print(matches_true.group(1))
            if ref_var != "":
                print(
                    "--------------------------------------------------------------------------------------------"
                )
                print(
                    "|            Spike Arrest Rate is Configured From KVM please update KVM                    |"
                )
                print(
                    "--------------------------------------------------------------------------------------------"
                )

            if (value_of_effective_count == "true") & (ref_var == ""):
                changed_spike_rate = int(no_of_mp) * int(only_digit)
                #print("Changed Spike rate "+str(changed_spike_rate))
                #print(current_path+"\\proxies"+"\\"+proxy_name_include_sa+"\\apiproxy\\policies\\"+name_sa+".xml")
                pyutil.filereplace(
                    current_path + "\\proxies" + "\\" + proxy_name_include_sa +
                    "\\apiproxy\\policies\\" + name_sa + ".xml",
                    "<UseEffectiveCount>true</UseEffectiveCount>", "")
                pyutil.filereplace(
                    current_path + "\\proxies" + "\\" + proxy_name_include_sa +
                    "\\apiproxy\\policies\\" + name_sa + ".xml",
                    "<Rate>" + original_spike_rate + "</Rate>", "<Rate>" +
                    str(changed_spike_rate) + "p" + unit_spike + "</Rate>")

        file_spike_arrest.close()
Ejemplo n.º 11
0
	def edit_statistic_collector(current_path,proxy_name_include_sc,name_sc,token,src_dc_file):
		referenced_var =''
		default_value_stats=0
		file_statistic_collector=open(current_path+"\\proxies"+"\\"+proxy_name_include_sc+"\\apiproxy\\policies"+"\\"+name_sc+".xml", 'r')
		lines=file_statistic_collector.readlines()
		for line in lines:
			match_ref_variable =re.search(r'\s*<Statistic.*ref="(.*?)"',line)
			if match_ref_variable:
				referenced_var=match_ref_variable.group(1)
				#print("<========================= Value of Referenced Var ======================>"+referenced_var)
			match_display_name =re.search(r'<DisplayName>(.*?)</DisplayName>',line)
			if match_display_name:
				policy_display_name=match_display_name.group(1)
			match_default_value =re.search(r'<Statistic .*>(.*?)</Statistic',line)
			if match_default_value:
				default_value_stats=match_default_value.group(1).strip()
				print("Printing =================> "+default_value_stats)

			
		file_statistic_collector.close()
		print("------------------------------------------------------")
		print("| Copying the required Data Capture  policy file     |")
		print("------------------------------------------------------")

		#src_file = 'C:\\Users\\SANTOSH\\Desktop\\DataCapture.xml'
		dest_dir = current_path+"\\proxies"+"\\"+proxy_name_include_sc+"\\apiproxy\\policies"
		shutil.copy(src_dc_file,dest_dir)
		print("------------------------------------------------------")
		print("|                   Copied                           |")	
		print("------------------------------------------------------")



		file_data_capture=open(current_path+"\\proxies"+"\\"+proxy_name_include_sc+"\\apiproxy\\policies"+"\\DataCapture.xml", 'r')
		lines =file_data_capture.readlines()
		for line in lines:
			#print(line)
			match_dc_file_name=re.search(r'DataCapture.*name="(.*?)"',line)
			if match_dc_file_name:
				m_dc_file_name=match_dc_file_name.group(1)
				#print(m_dc_file_name)	
			match_dc_var_name = re.search(r'<DataCollector>(.*?)</DataCollector>',line)
			if match_dc_var_name:
				dc_var_name = match_dc_var_name.group(1)
				#print(dc_var_name)
				print("DATA COLLECTOR VALUE : " +match_dc_var_name.group(1))
				dc_store_obj=Dc_store
				dc_store_obj.dc_store(token,dc_var_name)	
		file_data_capture.close()	


		pyutil.filereplace(current_path+"\\proxies"+"\\"+proxy_name_include_sc+"\\apiproxy\\policies\\"+m_dc_file_name+'.xml','<DataCapture name="DataCapture"','<DataCapture name="'+name_sc+'"')
		pyutil.filereplace(current_path+"\\proxies"+"\\"+proxy_name_include_sc+"\\apiproxy\\policies\\"+m_dc_file_name+'.xml',' <DisplayName>DataCapturepolicy</DisplayName>',' <DisplayName>'+policy_display_name+'</DisplayName>')
		if default_value_stats == 0:
			pyutil.filereplace(current_path+"\\proxies"+"\\"+proxy_name_include_sc+"\\apiproxy\\policies\\"+m_dc_file_name+'.xml','<Collect ref="existing-variable" default="0"/>','<Collect ref="'+referenced_var+'" default="0"/>')
		else:
			pyutil.filereplace(current_path+"\\proxies"+"\\"+proxy_name_include_sc+"\\apiproxy\\policies\\"+m_dc_file_name+'.xml','<Collect ref="existing-variable" default="0"/>','<Collect ref="'+referenced_var+'" default="'+default_value_stats+'"/>')
			print("------------------------------------------------------")
			print("|             Changes Applied                        |")
			print("------------------------------------------------------")


		
		os.remove(current_path+"\\proxies"+"\\"+proxy_name_include_sc+"\\apiproxy\\policies\\"+name_sc+".xml")
		print("------------------------------------------------------")
		print("!  Successfully deleted StatisticsCollector policy   |")
		print("------------------------------------------------------")
		#print(m_dc_file_name)
		print("------------------------------------------------------")
		print("!        Renaming the DataCapture Policy             |")
		print("------------------------------------------------------")
	
		os.rename(current_path+"\\proxies"+"\\"+proxy_name_include_sc+"\\apiproxy\\policies\\"+m_dc_file_name+'.xml', current_path+"\\proxies"+"\\"+proxy_name_include_sc+"\\apiproxy\\policies\\"+name_sc+".xml")
		print("------------------------------------------------------")
		print("|                 Renamed                            |")		
		print("------------------------------------------------------")
Ejemplo n.º 12
0
        print("KVM MAP IDENTIFIER " + kvm_name)
        os.rename(
            current_path + "\\proxies" +
            "\\create_kvm_values_demo\\apiproxy\\policies\\KVM.xml",
            current_path + "\\proxies" +
            "\\create_kvm_values_demo\\apiproxy\\policies\\kvm_" + kvm_name +
            ".xml")
        print("------------------------------------------------------")
        print("|                 Renamed                            |")
        print("------------------------------------------------------")

        ################################ Replacing Variable inside the KVM File ############################################
        pyutil.filereplace(
            current_path + "\\proxies" +
            "\\create_kvm_values_demo\\apiproxy\\policies\\kvm_" + kvm_name +
            '.xml', 'mapIdentifier="Basic-Auth"',
            'mapIdentifier="' + kvm_name + '"')
        pyutil.filereplace(
            current_path + "\\proxies" +
            "\\create_kvm_values_demo\\apiproxy\\policies\\kvm_" + kvm_name +
            '.xml', 'name="KVM_dummy"', 'name="kvm_' + kvm_name + '"')
        pyutil.filereplace(
            current_path + "\\proxies" +
            "\\create_kvm_values_demo\\apiproxy\\policies\\kvm_" + kvm_name +
            '.xml', '<DisplayName>KVM</DisplayName>',
            '<DisplayName>kvm_' + kvm_name + '</DisplayName>')

        q = q + data['name'] + "," + str(data['encrypted']) + ","
        list_of_kvm_values.append(data['name'])
        list_of_kvm_values.append(data['encrypted'])