@ -630,6 +630,12 @@ def create_publish_folders(folder_url):
if not os . path . isdir ( folder_url + " / " + " Internal " ) :
os . makedirs ( folder_url + " / " + " Internal " )
if not os . path . isdir ( folder_url + " / " + " Internal_Full_Update " ) :
os . makedirs ( folder_url + " / " + " Internal_Full_Update " )
if not os . path . isdir ( folder_url + " / " + " Global_Full_Update " ) :
os . makedirs ( folder_url + " / " + " Global_Full_Update " )
return True
except Exception as e :
@ -774,25 +780,34 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
' data ' : ' '
}
latest_pub_data = vehicle_data . copy ( )
''' Publish Ready Flags '''
publish_feature_finder = 0
feature_finder_tmp = [ ]
''' Create Folder For Publish '''
create_publish_folders ( folder_url )
full_update_folder_url = folder_url + " / " + " {} " . format ( publish_type ) + " _Full_Update "
file_path = folder_url + " / " + publish_type + " / " + \
vehicle . replace ( ' ' , ' - ' ) + ' -feature_finder ' + ' .json '
global_file_path = folder_url + " / " + ' Global ' + " / " + \
vehicle . replace ( ' ' , ' - ' ) + ' -feature_finder ' + ' .json '
full_update_file = full_update_folder_url + " / " + vehicle . replace ( ' ' , ' - ' ) + ' -feature_finder_full_update ' + ' .json '
# full_internal_update_file = full_update_folder_url+"/" + vehicle.replace(' ', '-') + '-feature_finder_full_update' + '.json'
global_full_update_path = folder_url + " / " + " Global_Full_Update "
check_glbl_full_updte = global_full_update_path + " / " + vehicle . replace ( ' ' , ' - ' ) + ' -feature_finder_full_update ' + ' .json '
''' Append Published Data to Json '''
logger . info (
f ' Repair Checksheet Data Append Start:: { vehicle } - { language } - { publish_type } ' )
f ' Feature Data Append Start::{ vehicle } - { language } - { publish_type } ' )
''' update existing global json file '''
if os . path . isfile ( global_file_path ) and publish_type == ' Internal ' :
with open ( global_file_path ) as f :
published_data = json . load ( f )
if os . path . isfile ( check_glbl_full_updte ) :
with open ( check_glbl_full_updte ) as f :
published_data = json . load ( f )
for i in parent :
feature_finder = feature_finder_data ( vehicle , language ,
publish_type , i . parent1 , i . variant )
@ -801,7 +816,8 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
feature_finder_tmp . append (
feature_finder [ ' data ' ] [ 0 ] )
feature_finder_tmp = create_df ( feature_finder_tmp )
vehi_data = compare_get_data ( { ' data ' : published_data [ ' data ' ] } , {
latest_pub_data [ ' data ' ] = feature_finder_tmp
vehi_data = compare_get_data ( { ' data ' : latest_pub_data [ ' data ' ] } , {
' data ' : feature_finder_tmp } )
if vehi_data :
find_distinct = set ( exisitng_var )
@ -811,7 +827,14 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
vehi_data , new_variant_name , feature_finder_tmp )
elif os . path . isfile ( file_path ) and publish_type == ' Global ' :
with open ( global_file_path ) as f :
frappe . log_error ( ' inside ' )
full_update_folder_url_internal = folder_url + " / " + " Internal_Full_Update "
#Remove Internal Full Update File On Global Publish
existing_internal_full_update = full_update_folder_url_internal + " / " + vehicle . replace ( ' ' , ' - ' ) + ' -feature_finder_full_update ' + ' .json '
frappe . log_error ( ' file_path ' + str ( existing_internal_full_update ) )
if os . path . isfile ( existing_internal_full_update ) :
os . remove ( existing_internal_full_update )
with open ( check_glbl_full_updte ) as f :
published_data = json . load ( f )
for i in parent :
feature_finder = feature_finder_data ( vehicle , language ,
@ -821,7 +844,8 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
feature_finder_tmp . append (
feature_finder [ ' data ' ] [ 0 ] )
feature_finder_tmp = create_df ( feature_finder_tmp )
vehi_data = compare_get_data ( { ' data ' : published_data [ ' data ' ] } , {
latest_pub_data [ ' data ' ] = feature_finder_tmp
vehi_data = compare_get_data ( { ' data ' : latest_pub_data [ ' data ' ] } , {
' data ' : feature_finder_tmp } )
if vehi_data :
find_distinct = set ( exisitng_var )
@ -830,27 +854,78 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
vehi_data = add_new_val (
vehi_data , new_variant_name , feature_finder_tmp )
else :
for i in parent :
feature_finder = feature_finder_data (
vehicle , language , publish_type , i . parent1 , i . variant )
if feature_finder [ ' status ' ] == 1 :
publish_feature_finder = 1
if len ( feature_finder [ ' data ' ] ) :
feature_finder_tmp . append (
feature_finder [ ' data ' ] [ 0 ] )
else :
frappe . throw ( ' failed to publish ' )
feature_finder_tmp = get_latest_data (
{ ' data ' : feature_finder_tmp } , { ' data ' : [ ] } )
#Existing Global or Internal Full Update
internal_full_update_check = full_update_folder_url = folder_url + " / " + " Internal_Full_Update "
check_full_update_file = internal_full_update_check + " / " + vehicle . replace ( ' ' , ' - ' ) + ' -feature_finder_full_update ' + ' .json '
if os . path . isfile ( check_full_update_file ) :
with open ( check_full_update_file ) as f :
published_data = json . load ( f )
for i in parent :
frappe . log_error ( " i " , str ( parent ) )
feature_finder = feature_finder_data (
vehicle , language , publish_type , i . parent1 , i . variant )
if feature_finder [ ' status ' ] == 1 :
publish_feature_finder = 1
if len ( feature_finder [ ' data ' ] ) :
feature_finder_tmp . append (
feature_finder [ ' data ' ] [ 0 ] )
else :
frappe . throw ( ' failed to publish ' )
feature_finder_tmp = create_df ( feature_finder_tmp )
latest_pub_data [ ' data ' ] = feature_finder_tmp
vehi_data = compare_get_data ( { ' data ' : latest_pub_data [ ' data ' ] } , {
' data ' : feature_finder_tmp } )
if vehi_data :
find_distinct = set ( exisitng_var )
new_variant_name = [
x for x in new_variant if x not in find_distinct ]
vehi_data = add_new_val (
vehi_data , new_variant_name , feature_finder_tmp )
vehi_data = create_df ( feature_finder_tmp )
vehicle_data [ ' data ' ] = vehi_data
#First Time Global Or Internal
else :
for i in parent :
frappe . log_error ( " 619 " , str ( parent ) )
feature_finder = feature_finder_data (
vehicle , language , publish_type , i . parent1 , i . variant )
if feature_finder [ ' status ' ] == 1 :
publish_feature_finder = 1
if len ( feature_finder [ ' data ' ] ) > 0 :
feature_finder_tmp . append (
feature_finder [ ' data ' ] [ 0 ] )
else :
frappe . throw ( ' failed to publish ' )
feature_finder_tmp = get_latest_data (
{ ' data ' : feature_finder_tmp } , { ' data ' : [ ] } )
frappe . log_error ( str ( feature_finder_tmp ) )
vehi_data = create_df ( feature_finder_tmp )
latest_pub_data [ ' data ' ] = vehi_data
if publish_type == " Global " :
full_update_folder_url_internal = folder_url + " / " + " Internal_Full_Update "
#Remove Internal Full Update File On Global Publish
existing_internal_full_update = full_update_folder_url_internal + " / " + vehicle . replace ( ' ' , ' - ' ) + ' -feature_finder_full_update ' + ' .json '
frappe . log_error ( ' file_path ' + str ( existing_internal_full_update ) )
if os . path . isfile ( existing_internal_full_update ) :
os . remove ( existing_internal_full_update )
""" Save publish file """
vehicle_data [ ' data ' ] = vehi_data
with open ( file_path , ' w ' ) as outfile :
outfile . write ( json . dumps ( latest_pub_data , indent = 4 , default = str ) )
with open ( full_update_file , ' w ' ) as outfile :
outfile . write ( json . dumps ( vehicle_data , indent = 4 , default = str ) )
logger . info (
f ' Repair Checksheet Data Append Start:: { vehicle } - { language } - { publish_type } ' )
@ -862,57 +937,68 @@ def feature_finder_publish(vehicle=None, vehicle_id=None,
frappe . throw ( ' Failed To Publish ' )
def qwik_service_publish ( vehicle = None , vehicle_id = None , variant = None ,
language = None , publish_type = None ,
release_description = None , parent = None ) :
def qwik_service_publish ( vehicle = None , vehicle_id = None ,
language = None , publish_type = None ,
release_description = None , parent = None ,
variant = None ) :
try :
logger_file = f ' { variant } - { language } - { publish_type } - Qwik_service '
logger = frappe . logger ( logger_file , allow_site = True , file_count = 100 )
logger_file = f ' { vehicle } - { language } - { publish_type } - { module_name } - { variant } '
logger = frappe . logger ( logger_file ,
allow_site = True , file_count = 100 )
logger . info (
f ' Qwik_service- { variant } - { language } - { publish_type } - { parent } ' )
f " start of fetching qwik_service data - { vehicle } - { language } - { module_name } - { variant } " )
folder_url = base_url + " / " + vehicle . replace ( ' ' , ' - ' ) + " / " + language
logger . info ( f ' Created Folder- { vehicle } - { language } - { publish_type } ' )
''' Publish Ready Flags '''
publish_qwik_service = 0
qwik_service_tmp = [ ]
qwik_service = ' '
''' Create Folder For Publish '''
create_publish_folders ( folder_url )
file_path = folder_url + " / " + publish_type + " / " + \
vehicle . replace ( ' ' , ' - ' ) + ' -qwik_service ' + ' .json '
global_file_path = folder_url + " / " + " Global " + " / " + \
vehicle . replace ( ' ' , ' - ' ) + ' -qwik_service ' + ' .json '
exising_internal_path = folder_url + " / " + " Internal " + " / " + \
vehicle . replace ( ' ' , ' - ' ) + ' -qwik_service ' + ' .json '
''' Append Published Data to Json '''
logger . info (
f ' Qwik_service Data Append Start:: { vehicle } - { language } - { publish_type } ' )
''' Final Json '''
vehicle_data = {
' vehicle ' : vehicle ,
' vehicle_myid ' : vehicle_id ,
' variant ' : variant ,
' publish_type ' : publish_type ,
' publish_description ' : release_description ,
' publish_language ' : language ,
' data ' : ' '
}
if os . path . isfile ( global_file_path ) and publish_type == ' Internal ' :
with open ( global_file_path ) as f :
published_data = json . load ( f )
latest_pub_data = vehicle_data . copy ( )
''' Publish Ready Flags '''
publish_qwik_service = 0
qwik_service_tmp = [ ]
''' Create Folder For Publish '''
create_publish_folders ( folder_url )
full_update_folder_url = folder_url + " / " + " {} " . format ( publish_type ) + " _Full_Update "
file_path = folder_url + " / " + publish_type + " / " + \
vehicle . replace ( ' ' , ' - ' ) + ' - qwik_service ' + ' .json '
global_file_path = folder_url + " / " + ' Global ' + " / " + \
vehicle . replace ( ' ' , ' - ' ) + ' - qwik_service ' + ' .json '
full_update_file = full_update_folder_url + " / " + vehicle . replace ( ' ' , ' - ' ) + ' - qwik_service_full_update ' + ' .json '
# full_internal_update_file = full_update_folder_url+"/" + vehicle.replace(' ', '-') + '-feature_finder_full_update' + '.json'
global_full_update_path = folder_url + " / " + " Global_Full_Update "
check_glbl_full_updte = global_full_update_path + " / " + vehicle . replace ( ' ' , ' - ' ) + ' - qwik_service_full_update ' + ' .json '
''' Append Published Data to Json '''
logger . info (
f ' qwik_service Data Append Start:: { vehicle } - { language } - { publish_type } ' )
''' update existing global json file '''
if os . path . isfile ( global_file_path ) and publish_type == ' Internal ' :
if os . path . isfile ( check_glbl_full_updte ) :
with open ( check_glbl_full_updte ) as f :
published_data = json . load ( f )
for i in parent :
qwik_service = qwik_service_data (
language , publish_type , i . variant , i . parent1 , vehicle )
if qwik_service [ ' status ' ] == 1 and len ( qwik_service [ ' data ' ] ) > 0 :
qwik_service = qwik_service_data ( vehicle , language ,
publish_type , i . parent1 , i . variant )
if qwik_service [ ' status ' ] == 1 :
publish_qwik_service = 1
qwik_service_tmp . append (
qwik_service [ ' data ' ] [ 0 ] )
qwik_service_tmp = create_df ( qwik_service_tmp )
vehi_data = compare_get_data ( { ' data ' : published_data [ ' data ' ] } , {
latest_pub_data [ ' data ' ] = qwik_service_tmp
vehi_data = compare_get_data ( { ' data ' : latest_pub_data [ ' data ' ] } , {
' data ' : qwik_service_tmp } )
if vehi_data :
find_distinct = set ( exisitng_var )
@ -921,20 +1007,26 @@ def qwik_service_publish(vehicle=None, vehicle_id=None, variant=None,
vehi_data = add_new_val (
vehi_data , new_variant_name , qwik_service_tmp )
elif os . path . isfile ( global_file_path ) and publish_type == ' Global ' :
with open ( global_file_path ) as f :
elif os . path . isfile ( file_path ) and publish_type == ' Global ' :
frappe . log_error ( ' inside ' )
full_update_folder_url_internal = folder_url + " / " + " Internal_Full_Update "
#Remove Internal Full Update File On Global Publish
existing_internal_full_update = full_update_folder_url_internal + " / " + vehicle . replace ( ' ' , ' - ' ) + ' -qwik_service_full_update ' + ' .json '
frappe . log_error ( ' file_path ' + str ( existing_internal_full_update ) )
if os . path . isfile ( existing_internal_full_update ) :
os . remove ( existing_internal_full_update )
with open ( check_glbl_full_updte ) as f :
published_data = json . load ( f )
for i in parent :
qwik_service = qwik_service_data (
language , publish_type , i . variant , i . parent1 , vehicle )
if qwik_service [ ' status ' ] == 1 and len ( qwik_service [ ' data ' ] ) > 0 :
qwik_service = qwik_service_data ( vehicle , language ,
publish_type , i . parent1 , i . variant )
if qwik_service [ ' status ' ] == 1 :
publish_qwik_service = 1
qwik_service_tmp . append (
qwik_service [ ' data ' ] [ 0 ] )
qwik_service_tmp = create_df ( qwik_service_tmp )
vehi_data = compare_get_data ( { ' data ' : published _data [ ' data ' ] } , {
latest_pub_data [ ' data ' ] = qwik_service_tmp
vehi_data = compare_get_data ( { ' data ' : latest_ pub_data[ ' data ' ] } , {
' data ' : qwik_service_tmp } )
if vehi_data :
find_distinct = set ( exisitng_var )
@ -943,32 +1035,93 @@ def qwik_service_publish(vehicle=None, vehicle_id=None, variant=None,
vehi_data = add_new_val (
vehi_data , new_variant_name , qwik_service_tmp )
else :
for i in parent :
qwik_service = qwik_service_data (
language , publish_type , i . variant , i . parent1 , vehicle )
if qwik_service [ ' status ' ] == 1 and len ( qwik_service [ ' data ' ] ) > 0 :
publish_qwik_service = 1
qwik_service_tmp . append (
qwik_service [ ' data ' ] [ 0 ] )
else :
frappe . throw ( ' failed to publish ' )
qwik_service_tmp = get_latest_data (
{ ' data ' : qwik_service_tmp } , { ' data ' : [ ] } )
vehi_data = create_df ( qwik_service_tmp )
#Existing Global or Internal Full Update
internal_full_update_check = full_update_folder_url = folder_url + " / " + " Internal_Full_Update "
check_full_update_file = internal_full_update_check + " / " + vehicle . replace ( ' ' , ' - ' ) + ' -qwik_service_full_update ' + ' .json '
if os . path . isfile ( check_full_update_file ) :
with open ( check_full_update_file ) as f :
published_data = json . load ( f )
for i in parent :
qwik_service = qwik_service_data (
vehicle , language , publish_type , i . parent1 , i . variant )
if qwik_service [ ' status ' ] == 1 :
publish_qwik_service = 1
if len ( qwik_service [ ' data ' ] ) :
qwik_service_tmp . append (
qwik_service [ ' data ' ] [ 0 ] )
else :
frappe . throw ( ' failed to publish ' )
qwik_service_tmp = create_df ( qwik_service_tmp )
latest_pub_data [ ' data ' ] = qwik_service_tmp
vehi_data = compare_get_data ( { ' data ' : latest_pub_data [ ' data ' ] } , {
' data ' : qwik_service_tmp } )
if vehi_data :
find_distinct = set ( exisitng_var )
new_variant_name = [
x for x in new_variant if x not in find_distinct ]
vehi_data = add_new_val (
vehi_data , new_variant_name , qwik_service_tmp )
if vehi_data :
find_distinct = set ( exisitng_var )
new_variant_name = [
x for x in new_variant if x not in find_distinct ]
vehi_data = add_new_val (
vehi_data , new_variant_name , qwik_service_tmp )
vehicle_data [ ' data ' ] = vehi_data
#First Time Global Or Internal
else :
for i in parent :
frappe . log_error ( " 211 " , str ( i ) )
qwik_service = qwik_service_data (
vehicle , language , publish_type , i . parent1 , i . variant )
if qwik_service [ ' status ' ] == 1 :
publish_qwik_service = 1
if len ( qwik_service [ ' data ' ] ) > 0 :
qwik_service_tmp . append (
qwik_service [ ' data ' ] [ 0 ] )
else :
frappe . throw ( ' failed to publish ' )
qwik_service_tmp = get_latest_data (
{ ' data ' : qwik_service_tmp } , { ' data ' : [ ] } )
frappe . log_error ( str ( qwik_service_tmp ) )
vehi_data = create_df ( qwik_service_tmp )
latest_pub_data [ ' data ' ] = vehi_data
if publish_type == " Global " :
full_update_folder_url_internal = folder_url + " / " + " Internal_Full_Update "
#Remove Internal Full Update File On Global Publish
existing_internal_full_update = full_update_folder_url_internal + " / " + vehicle . replace ( ' ' , ' - ' ) + ' -qwik_service_full_update ' + ' .json '
frappe . log_error ( ' file_path ' + str ( existing_internal_full_update ) )
if os . path . isfile ( existing_internal_full_update ) :
os . remove ( existing_internal_full_update )
""" Save publish file """
vehicle_data [ ' data ' ] = vehi_data
with open ( file_path , ' w ' ) as outfile :
outfile . write ( json . dumps ( latest_pub_data , indent = 4 , default = str ) )
with open ( full_update_file , ' w ' ) as outfile :
outfile . write ( json . dumps ( vehicle_data , indent = 4 , default = str ) )
except Exception as e :
logger . error (
f ' { variant } - { language } - { publish_type } - Qwik_service ' + str ( e ) )
logger . info (
f ' Repair Checksheet Data Append Start:: { vehicle } - { language } - { publish_type } ' )
return 1 , file_path
except Exception as e :
logger . info (
f ' { vehicle } - { language } - { publish_type } - { module_name } error in json creation ' + str ( e ) )
frappe . throw ( ' Failed To Publish ' )
def special_tool_publish ( vehicle , vehicle_id ,
publish_type , release_description ,
parent = None ) :
@ -987,9 +1140,9 @@ def special_tool_publish(vehicle, vehicle_id,
''' Create Folder For Publish '''
create_publish_folders ( folder_url )
file_path = folder_url + " / " + publish_type + " / " + \
file_path = folder_url + " / " + publish_type + " _Full_Update " + " / " + \
vehicle . replace ( ' ' , ' - ' ) + ' -special_tool ' + ' .json '
existing_global = folder_url + " / " + " Global " + " / " + \
existing_global = folder_url + " / " + " Global_Full_Update " + " / " + \
vehicle . replace ( ' ' , ' - ' ) + ' -special_tool ' + ' .json '
''' Append Published Data to Json '''
@ -1032,17 +1185,48 @@ def special_tool_publish(vehicle, vehicle_id,
' data ' : special_tool_tmp } )
else :
for i in parent :
special_tool = special_tool_data (
vehicle , publish_type , i . parent1 )
internal_full_update_check = folder_url + " / " + " Internal_Full_Update "
check_inter_full_update_file = internal_full_update_check + " / " + \
vehicle . replace ( ' ' , ' - ' ) + ' -special_tool ' + ' .json '
if special_tool [ ' status ' ] == 1 :
publish_special_tool = 1
if len ( special_tool [ ' data ' ] ) > 0 :
frappe . log_error ( str ( check_inter_full_update_file ) )
# check if Internal Full Update Already Exist
if os . path . isfile ( check_inter_full_update_file ) :
frappe . log_error ( ' inside_full_update ' )
with open ( check_inter_full_update_file ) as f :
published_data = json . load ( f )
for i in parent :
special_tool = special_tool_data (
vehicle , publish_type , i . parent1 )
if special_tool [ ' status ' ] == 1 and len ( special_tool [ ' data ' ] ) > 0 :
publish_special_tool = 1
special_tool_tmp . append (
special_tool [ ' data ' ] [ 0 ] )
special_tool_tmp = get_latest_data (
{ ' data ' : special_tool_tmp } , { ' data ' : [ ] } )
special_tool_tmp = get_latest_data ( { ' data ' : published_data [ ' data ' ] } , {
' data ' : special_tool_tmp } )
else :
for i in parent :
special_tool = special_tool_data (
vehicle , publish_type , i . parent1 )
if special_tool [ ' status ' ] == 1 :
publish_special_tool = 1
if len ( special_tool [ ' data ' ] ) > 0 :
special_tool_tmp . append (
special_tool [ ' data ' ] [ 0 ] )
special_tool_tmp = get_latest_data (
{ ' data ' : special_tool_tmp } , { ' data ' : [ ] } )
if publish_type == " Global " :
#Remove Internal Full Update File On Global Publish
internal_full_update_check = folder_url + " / " + " Internal_Full_Update "
check_inter_full_update_file = internal_full_update_check + " / " + \
vehicle . replace ( ' ' , ' - ' ) + ' -special_tool ' + ' .json '
if os . path . isfile ( check_inter_full_update_file ) :
os . remove ( check_inter_full_update_file )
if publish_special_tool == 1 :
""" Save publish file """
@ -1235,7 +1419,7 @@ def feature_finder_data(vehicle=None, language=None,
ff . features_names as feature_name , ff . feature_category , ff . display_order , ff . active_status ,
ffm . feature_pdf as pdf from ` tabFeature Finder ` ff left join ` tabFeature Finder Master ` ffm on
ff . features_names = ffm . feature_name
where ff . vehicle = " THAR " and ffm . vehicle = " {vehicle} "
where ff . vehicle = " {vehicle} " and ffm . vehicle = " {vehicle} "
and ff . variant = " {variant} "
and ff . language = " {language} " and ffm . language = " {language} " and ff . name = " {parent} " ;
""" , as_dict=1)