@ -484,12 +484,12 @@ def new_publish(args, publish_type, vehicle, language, version):
with open ( full_update_file_name , " w " ) as outfile :
outfile . write ( json . dumps ( json_file ) )
get_step_total_count ( full_update_file_name )
file_name = file_name
return True , file_name . split ( " public " ) [ 1 ]
file_name1 = file_name
return True , file_name1 . split ( " public " ) [ 1 ]
else :
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 :
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 "
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 + " / " + \
" %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 = " {} "
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 :
frappe . log_error ( ' inside ' )
prev_update_ver_internal = float ( pub_ver [ 1 ] [ " version " ] )
frappe . log_error ( ' version_internal ' +
str ( prev_update_ver_internal ) )
prev_full_internal_update_file = full_update_path_internal + vehicle + " / " + \
" %s - %s -full_v %s .json " % ( vehicle ,
language , prev_update_ver_internal )
if check_if_global_exist :
frappe . log_error ( ' inside1 ' )
prev_global_update_ver = check_if_global_exist [ 0 ] [ " version " ]
frappe . log_error ( ' version_global ' +
str ( prev_global_update_ver ) )
prev_global_file = full_update_path + vehicle + " / " + \
" %s - %s -full_v %s .json " % ( vehicle ,
language , prev_global_update_ver )
frappe . log_error ( ' prev_global ' + str ( prev_global_file ) )
file_flag , final_update_file = merge_json_files (
prev_global_file , file_name , full_update_file_name )
get_step_total_count ( final_update_file )
set_publish_flag ( publish_type , vehicle , language )
if file_flag :
return True , file_name . split ( " public " ) [ 1 ]
# return True, file_name
else :
return False , " File save issue "
# frappe.log_error('inside')
if pub_ver [ 1 ] [ ' publish_type ' ] == ' Internal ' :
prev_update_ver_internal = float ( pub_ver [ 1 ] [ " version " ] )
# frappe.log_error('version_internal' +
# str(prev_update_ver_internal))
prev_full_internal_update_file = full_update_path_internal + vehicle + " / " + \
" %s - %s -full_v %s .json " % ( vehicle ,
language , prev_update_ver_internal )
file_flag , final_update_file = merge_json_files (
prev_full_internal_update_file , file_name , full_update_file_name )
get_step_total_count ( final_update_file )
set_publish_flag ( publish_type , vehicle , language )
if file_flag :
return True , file_name . split ( " public " ) [ 1 ]
# return True, file_name
else :
return False , " File save issue "
elif pub_ver [ 1 ] [ ' publish_type ' ] == ' Global ' :
try :
with open ( full_update_file_name , " w " ) as outfile :
outfile . write ( json . dumps ( json_file ) )
get_step_total_count ( full_update_file_name )
file_name1 = file_name
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 :
frappe . log_error ( str ( ' first time ionternal ' ) )
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 )
else :
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 :
prev_update_ver = pub_ver [ 1 ] [ " version " ]
prev_full_update_file = full_update_path_internal + vehicle + " / " + \