@ -484,12 +484,12 @@ def new_publish(args, publish_type, vehicle, language, version):
with open ( full_update_file_name , " w " ) as outfile :
with open ( full_update_file_name , " w " ) as outfile :
outfile . write ( json . dumps ( json_file ) )
outfile . write ( json . dumps ( json_file ) )
get_step_total_count ( full_update_file_name )
get_step_total_count ( full_update_file_name )
file_name = file_name
file_name1 = file_name
return True , file_name . split ( " public " ) [ 1 ]
return True , file_name1 . split ( " public " ) [ 1 ]
else :
else :
pub_ver = frappe . db . sql ( """ SELECT vehicle,language,format(version,2) as version,modified,publish_type FROM tabPublish where vehicle = " {} "
pub_ver = frappe . db . sql ( """ SELECT vehicle,language,format(version,2) as version,modified,publish_type FROM tabPublish where vehicle = " {} "
and publish_type = " Global " AND ` language ` = " {} " order by modified desc limit 2 ; """ .format(vehicle, language), as_dict=1)
and publish_type = " Global " AND ` language ` = " {} " and publish_module = " Automotive System " order by modified desc work 2 ; """ .format(vehicle, language), as_dict=1)
if pub_ver :
if pub_ver :
prev_update_ver = pub_ver [ 1 ] [ " version " ]
prev_update_ver = pub_ver [ 1 ] [ " version " ]
@ -508,45 +508,49 @@ def new_publish(args, publish_type, vehicle, language, version):
return False , " File save issue "
return False , " File save issue "
if publish_type . lower ( ) == " internal " and len ( check_if_global_exist ) > 0 :
if publish_type . lower ( ) == " internal " and len ( check_if_global_exist ) > 0 :
frappe . log_error ( str ( ' already global published ' ) )
# frappe.log_error(str('already global published') )
full_update_file_name = full_update_path_internal + vehicle + " / " + \
full_update_file_name = full_update_path_internal + vehicle + " / " + \
" %s - %s -full_v %s .json " % ( vehicle , language , version )
" %s - %s -full_v %s .json " % ( vehicle , language , version )
frappe . log_error ( ' update file ' + str ( full_update_file_name ) )
# frappe.log_error('update file' + str(full_update_file_name) )
pub_ver = frappe . db . sql ( """ SELECT vehicle,language,format(version,2) as version,modified,publish_type FROM tabPublish where vehicle = " {} "
pub_ver = frappe . db . sql ( """ SELECT vehicle,language,format(version,2) as version,modified,publish_type FROM tabPublish where vehicle = " {} "
and publish_type = " Internal " AND ` language ` = " {} " and publish_module = " Automotive System " order by modified desc limit 2 ; """ .format(vehicle, language), as_dict=1)
and ` language ` = " {} " and publish_module = " Automotive System " order by modified desc limit 2 ; """ .format(vehicle, language), as_dict=1)
if pub_ver :
if pub_ver :
frappe . log_error ( ' inside ' )
# frappe.log_error('inside')
prev_update_ver_internal = float ( pub_ver [ 1 ] [ " version " ] )
if pub_ver [ 1 ] [ ' publish_type ' ] == ' Internal ' :
frappe . log_error ( ' version_internal ' +
prev_update_ver_internal = float ( pub_ver [ 1 ] [ " version " ] )
str ( prev_update_ver_internal ) )
# frappe.log_error('version_internal' +
prev_full_internal_update_file = full_update_path_internal + vehicle + " / " + \
# str(prev_update_ver_internal))
" %s - %s -full_v %s .json " % ( vehicle ,
prev_full_internal_update_file = full_update_path_internal + vehicle + " / " + \
language , prev_update_ver_internal )
" %s - %s -full_v %s .json " % ( vehicle ,
if check_if_global_exist :
language , prev_update_ver_internal )
frappe . log_error ( ' inside1 ' )
file_flag , final_update_file = merge_json_files (
prev_global_update_ver = check_if_global_exist [ 0 ] [ " version " ]
prev_full_internal_update_file , file_name , full_update_file_name )
frappe . log_error ( ' version_global ' +
str ( prev_global_update_ver ) )
get_step_total_count ( final_update_file )
prev_global_file = full_update_path + vehicle + " / " + \
set_publish_flag ( publish_type , vehicle , language )
" %s - %s -full_v %s .json " % ( vehicle ,
if file_flag :
language , prev_global_update_ver )
return True , file_name . split ( " public " ) [ 1 ]
frappe . log_error ( ' prev_global ' + str ( prev_global_file ) )
# return True, file_name
else :
file_flag , final_update_file = merge_json_files (
return False , " File save issue "
prev_global_file , file_name , full_update_file_name )
get_step_total_count ( final_update_file )
elif pub_ver [ 1 ] [ ' publish_type ' ] == ' Global ' :
set_publish_flag ( publish_type , vehicle , language )
try :
if file_flag :
with open ( full_update_file_name , " w " ) as outfile :
return True , file_name . split ( " public " ) [ 1 ]
outfile . write ( json . dumps ( json_file ) )
# return True, file_name
get_step_total_count ( full_update_file_name )
else :
file_name1 = file_name
return False , " File save issue "
set_publish_flag ( publish_type , vehicle , language )
file_flag = True
except Exception as e :
file_flag = True
if file_flag :
return True , file_name . split ( " public " ) [ 1 ]
# return True, file_name
else :
return False , " File save issue "
# frappe.log_error("global exists")
# last_fullupdate_file = frappe.db.sql(""" SELECT vehicle,language,format(version,2) as version,modified,publish_type FROM tabPublish where vehicle = "{}"
# and publish_type = "Internal" AND `language` = "{}" order by modified desc limit 2 ;""".format(vehicle, language), as_dict=1)
# if last_fullupdate_file:
# pass
else :
else :
frappe . log_error ( str ( ' first time ionternal ' ) )
frappe . log_error ( str ( ' first time ionternal ' ) )
full_update_file_name = full_update_path_internal + vehicle + " / " + \
full_update_file_name = full_update_path_internal + vehicle + " / " + \
@ -558,7 +562,7 @@ def new_publish(args, publish_type, vehicle, language, version):
get_step_total_count ( full_update_file_name )
get_step_total_count ( full_update_file_name )
else :
else :
pub_ver = frappe . db . sql ( """ SELECT vehicle,language,format(version,2) as version,modified,publish_type FROM tabPublish where vehicle = " {} "
pub_ver = frappe . db . sql ( """ SELECT vehicle,language,format(version,2) as version,modified,publish_type FROM tabPublish where vehicle = " {} "
and publish_type = " Internal " AND ` language ` = " {} " order by modified desc limit 2 ; """ .format(vehicle, language), as_dict=1)
and publish_type = " Internal " AND ` language ` = " {} " and publish_module = " Automotive System " order by modified desc limit 2 ; """ .format(vehicle, language), as_dict=1)
if pub_ver :
if pub_ver :
prev_update_ver = pub_ver [ 1 ] [ " version " ]
prev_update_ver = pub_ver [ 1 ] [ " version " ]
prev_full_update_file = full_update_path_internal + vehicle + " / " + \
prev_full_update_file = full_update_path_internal + vehicle + " / " + \