3333import subprocess
3434import time
3535import logging
36+ import sys
3637
3738from package import Package , Bridge_SConscript , Kconfig_file , Package_json_file , Sconscript_file
3839from vars import Import , Export
3940from string import Template
4041from cmd_menuconfig import find_macro_in_config
4142
43+
4244"""package command"""
4345
4446
@@ -442,9 +444,8 @@ def update_latest_packages(read_back_pkgs_json, bsp_packages_path):
442444 mirror_url = get_url_from_mirror_server (
443445 payload_pkgs_name_in_json , pkg ['ver' ])
444446
445- #print(os.getcwd())
446-
447- #print(repo_path)
447+ # print(os.getcwd())
448+ # print(repo_path)
448449
449450 if mirror_url [0 ] != None :
450451 cmd = 'git remote set-url origin ' + mirror_url [0 ]
@@ -598,7 +599,7 @@ def __init__(self, log_name, clevel=logging.DEBUG):
598599 self .logger = logging .getLogger (log_name )
599600 self .logger .setLevel (logging .DEBUG )
600601 fmt = logging .Formatter (
601- '[%(levelname)s] %(filename)s %(funcName)s %(lineno)d %(message)s' )
602+ '%(asctime)s [%(levelname)s] [%(filename)s] %(message)s' )
602603
603604 # set cmd log
604605 sh = logging .StreamHandler ()
@@ -631,6 +632,11 @@ def package_update(isDeleteOld=False):
631632 remind the user saved the modified file.
632633 """
633634
635+ pkgs_update_log = Logger ('pkgs_update' , logging .ERROR )
636+
637+ pkgs_update_log .info (
638+ '[Line: %d][Message : Begin to update packages]' % sys ._getframe ().f_lineno )
639+
634640 bsp_root = Import ('bsp_root' )
635641 env_root = Import ('env_root' )
636642
@@ -643,8 +649,11 @@ def package_update(isDeleteOld=False):
643649 bsp_packages_path = sys_value [3 ]
644650 dbsqlite_pathname = sys_value [4 ]
645651
646- #print "newpkgs:",newpkgs
647- #print "oldpkgs:",oldpkgs
652+ # print "newpkgs:",newpkgs
653+ # print "oldpkgs:",oldpkgs
654+
655+ pkgs_update_log .info (
656+ '[Line: %d][Message : Begin to remove packages]' % sys ._getframe ().f_lineno )
648657
649658 # 1.in old ,not in new : Software packages that need to be removed.
650659 casedelete = sub_list (oldpkgs , newpkgs )
@@ -711,6 +720,9 @@ def package_update(isDeleteOld=False):
711720 # If the package download fails, record it, and then download again when
712721 # the update command is executed.
713722
723+ pkgs_update_log .info (
724+ '[Line: %d][Message : Begin to download packages]' % sys ._getframe ().f_lineno )
725+
714726 casedownload = sub_list (newpkgs , oldpkgs )
715727 # print 'in new not in old:', casedownload
716728 pkgs_download_fail_list = []
@@ -726,9 +738,14 @@ def package_update(isDeleteOld=False):
726738 print pkg , 'download failed.'
727739 flag = False
728740
741+ pkgs_update_log .info (
742+ '[Line: %d][Message : Get the list of packages that have been updated]' % sys ._getframe ().f_lineno )
743+
729744 # Get the currently updated configuration.
730745 newpkgs = sub_list (newpkgs , pkgs_download_fail_list )
731746
747+ pkgs_update_log .info (
748+ '[Line: %d][Message : Print the list of software packages that failed to download]' % sys ._getframe ().f_lineno )
732749 # Give hints based on the success of the download.
733750
734751 if len (pkgs_download_fail_list ):
@@ -743,10 +760,16 @@ def package_update(isDeleteOld=False):
743760 # print("write to %s" % pkgs_fn)
744761 # print("newpkgs %s" % newpkgs)
745762
763+ pkgs_update_log .info (
764+ '[Line: %d][Message : Write to pkgs.json file]' % sys ._getframe ().f_lineno )
765+
746766 pkgs_file = file (pkgs_fn , 'w' )
747767 pkgs_file .write (json .dumps (newpkgs , indent = 1 ))
748768 pkgs_file .close ()
749769
770+ pkgs_update_log .info (
771+ '[Line: %d][Message : Write to SConscript file]' % sys ._getframe ().f_lineno )
772+
750773 # update SConscript file
751774 if not os .path .isfile (os .path .join (bsp_packages_path , 'SConscript' )):
752775 bridge_script = file (os .path .join (
@@ -795,6 +818,9 @@ def package_update(isDeleteOld=False):
795818 if get_flag != None :
796819 flag = get_flag
797820
821+ pkgs_update_log .info (
822+ '[Line: %d][Message : Begin to update latest version packages]' % sys ._getframe ().f_lineno )
823+
798824 # Update the software packages, which the version is 'latest'
799825 try :
800826 update_latest_packages (read_back_pkgs_json , bsp_packages_path )
0 commit comments