Skip to content

Commit

Permalink
Ver 2.3.4
Browse files Browse the repository at this point in the history
Ver 2.3.4
  • Loading branch information
yuhsukeogawa authored Dec 21, 2024
1 parent f2a9a12 commit 5a0dd15
Show file tree
Hide file tree
Showing 18 changed files with 368 additions and 251 deletions.
19 changes: 3 additions & 16 deletions network_sketcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,25 +690,12 @@ def sub_master_extention_2(self):
self.sub3_5_button_1 = tk.Button(self.sub3_5_1, text=" IP Address table ", font=("", 12), command=lambda: self.click_action_sub('self.sub3_5_button_1','dummy'))
self.sub3_5_button_1.grid(row=6, column=0, sticky='W', padx=20, pady=5)

'''# Export to the Summary Diagram
self.sub3_5_button_2 = tk.Button(self.sub3_5_1, text=" Summary Diagram ", font=("", 12), command=lambda: self.click_action_sub('self.sub3_5_button_2','dummy'))
self.sub3_5_button_2.grid(row=7, column=0, sticky='W', padx=20, pady=5)
self.sub3_4_3_entry_1 = tk.Entry(self.sub3_5_1, font=("", 12)) # for report'''


def click_action_sub(self, click_value, target_area_name):
if click_value == 'self.sub3_5_button_1': # select IP address table
###export_ip_report
ns_extensions.ip_report.export_ip_report(self, target_area_name)
ns_def.messagebox_file_open(str(self.outFileTxt_11_3.get()))

'''if click_value == 'self.sub3_5_button_2': # select export_summary_diagram
###export_summary_diagram
dummy = ''
ns_extensions.summary_diagram.export_summary_diagram(self, dummy)
ns_def.messagebox_file_open(str(self.outFileTxt_11_3.get()))'''

if click_value == 'self.sub3_4_button_1': # select Run
#change target area name to N/A
if target_area_name == '_WAN(Way_Point)_':
Expand Down Expand Up @@ -756,7 +743,7 @@ def click_action_sub(self, click_value, target_area_name):
ns_def.messagebox_file_open(self.output_ppt_file) #Add at Ver 2.3.1(a)

if click_value == 'self.self.sub2_6_button_2': # Click "VPNs on L3"
print('--- Click VPNs on L3 ---')
#print('--- Click VPNs on L3 ---')
self.click_value = 'L3-4-1'
self.click_value_VPN = 'VPN-1-3'

Expand Down Expand Up @@ -847,7 +834,7 @@ def click_action_sub3_1(self, click_value,push_array):
self.sub3_1_label_4 = tk.Label(self.sub3_1, textvariable=self.text_sub3_1, font=("", 10), background="#E5F4F7")
self.sub3_1_label_4.grid(row=2, column=1, columnspan=3, sticky='W', padx=5, pady=20)
#ns_front_run.sub_excel_master_1(self, file_type_array)
print('Update to the Master file')
print('--- Update to the Master file ---')

### pre-defined for dev parameter
self.inFileTxt_11_1 = tk.Entry(self.sub3_1)
Expand Down Expand Up @@ -955,7 +942,7 @@ def click_action_sub3_1(self, click_value,push_array):
self.click_action_sub('self.self.sub2_5_button_3', push_array)
self.click_value_2nd = ''
if ns_def.return_os_slash() == '\\\\': # add ver 2.1.1 for bug fix on Mac OS
print(' # add ver 2.1.1 for bug fix on Mac OS', ns_def.return_os_slash())
#print(' # add ver 2.1.1 for bug fix on Mac OS', ns_def.return_os_slash())
subprocess.Popen(full_filepath_device, shell=True)

### open master panel
Expand Down
132 changes: 52 additions & 80 deletions ns_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_l3_segments(self):
excel_maseter_file = self.inFileTxt_L3_3_1.get()

self.result_get_l2_broadcast_domains = get_l2_broadcast_domains.run(self, excel_maseter_file) ## 'self.update_l2_table_array, device_l2_boradcast_domain_array, device_l2_directly_l3vport_array, device_l2_other_array, marged_l2_broadcast_group_array'
print('--- get_l3_segments ---')
#print('--- get_l3_segments ---')
#print('--- self.target_l2_broadcast_group_array ---')
#print(self.target_l2_broadcast_group_array)

Expand Down Expand Up @@ -126,7 +126,8 @@ def check_file_type(full_filepath):
return (['ERROR','Please enter a PPT file that does not contain IF tags'])

except Exception as e:
print('[info] Exception handling with check_file_type')
#print('[info] Exception handling with check_file_type')
flag_exception_dummy = True

return_type_array = ['PPT_SKECH','PPT_SKECH']

Expand Down Expand Up @@ -204,7 +205,7 @@ def write_excel_meta(master_excel_meta, excel_file_path, worksheet_name, section
:return: none
'''

print(excel_file_path, worksheet_name, section_write_to)
#print(excel_file_path, worksheet_name, section_write_to)
wb = openpyxl.load_workbook(excel_file_path)
wb.active = wb[worksheet_name]

Expand Down Expand Up @@ -260,7 +261,7 @@ def overwrite_excel_meta(master_excel_meta, excel_file_path, worksheet_name, sec
:return: none
'''

print(excel_file_path, worksheet_name, section_write_to)
#print(excel_file_path, worksheet_name, section_write_to)
wb = openpyxl.load_workbook(excel_file_path)
wb.active = wb[worksheet_name]

Expand Down Expand Up @@ -347,78 +348,55 @@ def return_shape_tuple(current_shape_array ,start_row):

updated_master_grid_array = []
device_name_array = []
kari_master_grid_array = []

for tmp_master_grid_array in master_grid_array:
# print('###############')
# print(tmp_master_grid_array)
for tmp_tmp_master_grid_array in tmp_master_grid_array:
# print(tmp_tmp_master_grid_array)
device_name_array.append(tmp_tmp_master_grid_array[1])
# print('###############')
# print(device_name_array)
kari_master_grid_array.append(tmp_tmp_master_grid_array)
#print('--- device_name_array ---')
#print(device_name_array)

vertical_key_array = []
used_device_array = []

for tmp_device_name_array in device_name_array:
flag_no_match = True
target = tmp_device_name_array
result = None

for sublist in master_grid_array:
for item in sublist:
if item[1] == target:
result = item
if tmp_device_name_array not in used_device_array:
#print('#####tmp_device_name_array,used_device_array,vertical_key_array',tmp_device_name_array,used_device_array,vertical_key_array)
target = tmp_device_name_array
result = None

for kari_kari_master_grid_array in kari_master_grid_array:
if kari_kari_master_grid_array[1] == target:
result = kari_kari_master_grid_array
break
if result:
break

for sublist in master_grid_array:
for item in sublist:
if item[1] not in used_device_array:
# print('###used_device_array### ', item[1],used_device_array)
if result[2] < item[2] + item[4] and result[2] > item[2]:
# print('@@left type@@ ', item)
flag_no_match = False
if result not in vertical_key_array and result[1] not in used_device_array:
vertical_key_array.append(result)
used_device_array.append(item[1])

if result[2] + result[4] > item[2] and result[2] + result[4] < item[2] + item[4]:
# print('@@right type@@ ', item)
flag_no_match = False
if result not in vertical_key_array and result[1] not in used_device_array:
vertical_key_array.append(result)
used_device_array.append(item[1])

if result[2] < item[2] and result[2] + result[4] > item[2] + item[4]:
# print('@@big type@@ ', item)
flag_no_match = False
if result not in vertical_key_array and result[1] not in used_device_array:
vertical_key_array.append(result)
used_device_array.append(item[1])

if result[2] > item[2] and result[2] + result[4] < item[2] + item[4]:
# print('@@small type@@ ', item)
flag_no_match = False
if result not in vertical_key_array and result[1] not in used_device_array:
vertical_key_array.append(result)
used_device_array.append(item[1])

if result[2] == item[2] and result[2] + result[4] == item[2] + item[4] and result[1] != item[1]:
#print('@@equal type@@ ', item)
flag_no_match = False
if result not in vertical_key_array and result[1] not in used_device_array:
vertical_key_array.append(result)
used_device_array.append(item[1])

if flag_no_match == True and result[1] not in used_device_array:
vertical_key_array.append(result)

#print('####vertical_key_array####')
#print(vertical_key_array, len(vertical_key_array))
if result not in vertical_key_array and result[1] not in used_device_array:
vertical_key_array.append(result)
used_device_array.append(result)

except_array = []

for sublist in master_grid_array:
except_array.extend(sublist)
flag_1st_match = False

#re-make at ver 2.3.4
for item in sublist:
if ((result[2] < item[2] + item[4] and result[2] > item[2]) or \
(result[2] + result[4] > item[2] and result[2] + result[4] < item[2] + item[4]) or \
(result[2] < item[2] and result[2] + result[4] > item[2] + item[4]) or \
(result[2] > item[2] and result[2] + result[4] < item[2] + item[4]) or \
(result[2] == item[2] and result[2] + result[4] == item[2] + item[4] and result[1] != item[1])) and \
(item[1] not in used_device_array) and (flag_1st_match == False or item not in except_array):
used_device_array.append(item[1])
except_array.remove(item)
flag_1st_match = True

# Remove duplicates by converting lists to tuples, adding to a set, and converting back to lists
vertical_key_array = [list(t) for t in set(tuple(item) for item in vertical_key_array)]
#print(vertical_key_array, len(vertical_key_array))

vertical_key_array_2 = []
for tmp_vertical_key_array in vertical_key_array:
vertical_key_array_2.append(
Expand All @@ -431,8 +409,8 @@ def return_shape_tuple(current_shape_array ,start_row):
#print(vertical_key_array_2)

for tmp_master_grid_array in master_grid_array:
# print('####### tmp_master_grid_array ########')
# print(tmp_master_grid_array)
#print('####### tmp_master_grid_array ########')
#print(tmp_master_grid_array)

import copy
updated_vertical_key_array_2 = copy.deepcopy(vertical_key_array_2)
Expand All @@ -441,38 +419,31 @@ def return_shape_tuple(current_shape_array ,start_row):
for tmp_tmp_master_grid_array in tmp_master_grid_array:

if tmp_tmp_master_grid_array not in updated_vertical_key_array_2:
if tmp_vertical_key_array_2[2] + tmp_vertical_key_array_2[4] >= tmp_tmp_master_grid_array[2] and \
tmp_vertical_key_array_2[2] <= tmp_tmp_master_grid_array[2]:
if tmp_vertical_key_array_2[2] + tmp_vertical_key_array_2[4] > tmp_tmp_master_grid_array[2] and tmp_vertical_key_array_2[2] < tmp_tmp_master_grid_array[2]:
updated_vertical_key_array_2[i] = tmp_tmp_master_grid_array
break
elif tmp_vertical_key_array_2[2] >= tmp_tmp_master_grid_array[2] and tmp_vertical_key_array_2[2] + \
tmp_vertical_key_array_2[4] <= tmp_tmp_master_grid_array[2] + tmp_tmp_master_grid_array[4]:
elif tmp_vertical_key_array_2[2] > tmp_tmp_master_grid_array[2] and tmp_vertical_key_array_2[2] + tmp_vertical_key_array_2[4] < tmp_tmp_master_grid_array[2] + tmp_tmp_master_grid_array[4]:
updated_vertical_key_array_2[i] = tmp_tmp_master_grid_array
break
elif tmp_vertical_key_array_2[2] + tmp_vertical_key_array_2[4] >= tmp_tmp_master_grid_array[2] + \
tmp_tmp_master_grid_array[4] and tmp_vertical_key_array_2[2] <= tmp_tmp_master_grid_array[
2] + tmp_tmp_master_grid_array[4]:
elif tmp_vertical_key_array_2[2] + tmp_vertical_key_array_2[4] >= tmp_tmp_master_grid_array[2] + tmp_tmp_master_grid_array[4] and tmp_vertical_key_array_2[2] < tmp_tmp_master_grid_array[2] + tmp_tmp_master_grid_array[4]:
updated_vertical_key_array_2[i] = tmp_tmp_master_grid_array
break
elif tmp_vertical_key_array_2[2] <= tmp_tmp_master_grid_array[2] and tmp_vertical_key_array_2[2] + \
tmp_vertical_key_array_2[4] >= tmp_tmp_master_grid_array[2] + tmp_tmp_master_grid_array[4]:
elif tmp_vertical_key_array_2[2] < tmp_tmp_master_grid_array[2] and tmp_vertical_key_array_2[2] + tmp_vertical_key_array_2[4] > tmp_tmp_master_grid_array[2] + tmp_tmp_master_grid_array[4]:
updated_vertical_key_array_2[i] = tmp_tmp_master_grid_array
break
elif tmp_vertical_key_array_2[2] == tmp_tmp_master_grid_array[2] and tmp_vertical_key_array_2[4] == \
tmp_tmp_master_grid_array[4]:
elif tmp_vertical_key_array_2[2] == tmp_tmp_master_grid_array[2] and tmp_vertical_key_array_2[4] == tmp_tmp_master_grid_array[4]:
updated_vertical_key_array_2[i] = tmp_tmp_master_grid_array
break

# print(updated_vertical_key_array_2,len(updated_vertical_key_array_2))
#print(updated_vertical_key_array_2,len(updated_vertical_key_array_2))
updated_master_grid_array.append(updated_vertical_key_array_2)

#print('--- updated_master_grid_array ---')
#print(updated_master_grid_array)

master_grid_array = copy.deepcopy(updated_master_grid_array)
print('--- master_grid_array ---')
#print('--- master_grid_array ---')
#print(master_grid_array)
'''Addition completed(ver 2.2.2)'''

# make the tuple format
tuple_grid_array = {}
tuple_grid_array[start_row, 1] = master_grid_array[0][0][0]
Expand Down Expand Up @@ -692,6 +663,7 @@ def convert_tuple_to_array(tmp_master_data_tuple):
master_data_array.append([tmp_num, tmp_tmp_array])
return(master_data_array)


### return folder and wp name array from master excel file ###
def get_folder_wp_array_from_master(ws_name, ppt_meta_file):
input_ppt_mata_excel = openpyxl.load_workbook(ppt_meta_file)
Expand Down
6 changes: 3 additions & 3 deletions ns_egt_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def create_excel_gui_tree(input_excel_name,output_excel_name,NEW_OR_ADD,egt_make

##### Main script prepared #####
input_tree_excel = openpyxl.load_workbook(input_excel_name)
print('Read the input excel file -> ' + input_excel_name)
#print('Read the input excel file -> ' + input_excel_name)

##### NEW Sheet , Insert paragraph##
if NEW_OR_ADD == 'ADD':
Expand Down Expand Up @@ -321,14 +321,14 @@ def create_excel_gui_tree(input_excel_name,output_excel_name,NEW_OR_ADD,egt_make
output_tree_excel.active.cell(output_row, column).value = num_to_bullet_front[column] + input_tree_excel.active.cell(input_row, column).value + num_to_bullet_back[column]
number_of_sheets += 1
first_sheet_name = str(output_tree_excel.active.title)
print('Create a new sheet -> ' + output_tree_excel.active.cell(output_row, column).value)
#print('Create a new sheet -> ' + output_tree_excel.active.cell(output_row, column).value)
else:
output_row = 1
output_tree_excel.create_sheet(title=str(input_tree_excel.active.cell(input_row, column).value))
output_tree_excel.active = output_tree_excel[str(input_tree_excel.active.cell(input_row, column).value)]
output_tree_excel.active.cell(output_row, column).value = num_to_bullet_front[column] + input_tree_excel.active.cell(input_row, column).value + num_to_bullet_back[column]
number_of_sheets += 1
print('Create a new sheet -> ' + output_tree_excel.active.cell(output_row, column).value)
#print('Create a new sheet -> ' + output_tree_excel.active.cell(output_row, column).value)

output_tree_excel.active.row_dimensions[output_row].height = first_paragraph_height
output_tree_excel.active.cell(output_row, column).font = first_paragraph_font
Expand Down
12 changes: 6 additions & 6 deletions ns_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def get_folder_list(self):
return return_array

def get_auto_ip_param(self,target_area_name):
print('--- get_auto_ip_param ---')
#print('--- get_auto_ip_param ---')
#print(target_area_name)

if target_area_name == "_WAN(Way_Point)_":
Expand Down Expand Up @@ -452,7 +452,7 @@ def get_auto_ip_param(self,target_area_name):
self.sub3_4_3_entry_1.insert(0, use_network)

def run_auto_ip(self,target_area_name):
print('--- run_auto_ip ---')
#print('--- run_auto_ip ---')
l3_segment_group_array = ns_def.get_l3_segments(self)
#print(l3_segment_group_array)

Expand All @@ -462,7 +462,7 @@ def run_auto_ip(self,target_area_name):
for tmp_tmp_l3_segment_group_array in tmp_l3_segment_group_array:
if tmp_tmp_l3_segment_group_array[4] != '':
exist_ip_list.append(tmp_tmp_l3_segment_group_array[4])
print('--- exist_ip_list ---')
#print('--- exist_ip_list ---')
#print(exist_ip_list)

# Set to store unique networks without duplicates
Expand All @@ -478,7 +478,7 @@ def run_auto_ip(self,target_area_name):
unique_networks.add(network)

# Print the list of unique network addresses in CIDR notation
print("--- Unique network addresses in CIDR notation: ---")
#print("--- Unique network addresses in CIDR notation: ---")
#for network in sorted(unique_networks):
# print(network.with_prefixlen)

Expand Down Expand Up @@ -586,7 +586,7 @@ def run_auto_ip(self,target_area_name):

unique_networks.add(subnet)

print('--- ip_assigned_l3_segment_group_array ---')
#print('--- ip_assigned_l3_segment_group_array ---')
#print(ip_assigned_l3_segment_group_array)

'''
Expand Down Expand Up @@ -615,7 +615,7 @@ def run_auto_ip(self,target_area_name):
if flag_l3_if_match == False:
updated_l3_table_array.append(tmp_l3_table_array)

print('--- updated_l3_table_array ---')
#print('--- updated_l3_table_array ---')
#print(updated_l3_table_array)

'''
Expand Down
Loading

0 comments on commit 5a0dd15

Please sign in to comment.