@@ -2031,10 +2031,11 @@ def openInNewTerm(project=None,g2script=None,pythonapp=sys.executable):
20312031
20322032if __name__ == '__main__' :
20332033 '''What follows is called to update (or downdate) GSAS-II in a
2034- separate process.
2034+ separate process. This is also called for background tasks such as
2035+ performing a "git fetch" task or getting current tag information from
2036+ github.
20352037 '''
20362038 # check what type of update is being called for
2037- import git
20382039 gitUpdate = False
20392040 preupdateType = None
20402041 updateType = None
@@ -2096,6 +2097,11 @@ def openInNewTerm(project=None,g2script=None,pythonapp=sys.executable):
20962097 print ('invalid form for --git-regress' )
20972098 help = True
20982099 break
2100+ try :
2101+ import git
2102+ except :
2103+ print ('Import of git failed for --git-regress' )
2104+ sys .exit ()
20992105 gitversion = argsplit [1 ]
21002106 # make sure the version or tag supplied is valid and convert to
21012107 # a full sha hash
@@ -2242,23 +2248,23 @@ def openInNewTerm(project=None,g2script=None,pythonapp=sys.executable):
22422248 fp .close ()
22432249 sys .exit ()
22442250
2251+ try :
2252+ import git
2253+ except :
2254+ print (f'Import of git failed. { updateType } update mode { preupdateType } ' )
2255+ sys .exit ()
2256+
22452257 if gitUpdate :
22462258 import time
22472259 time .sleep (1 ) # delay to give the main process a chance to exit
22482260 # so we don't change code for a running process
22492261 # windows does not like that
2250- try :
2251- import git
2252- except :
2253- print ('git import failed' )
2254- sys .exit ()
2255- try :
2256- g2repo = openGitRepo (path2GSAS2 )
2257- except Exception as msg :
2258- print (f'Update failed with message { msg } \n ' )
2259- sys .exit ()
2260- print ('git repo opened' )
2261-
2262+ try :
2263+ g2repo = openGitRepo (path2GSAS2 )
2264+ except Exception as msg :
2265+ print (f'Update failed with message { msg } \n ' )
2266+ sys .exit ()
2267+ print ('git repo opened' )
22622268 if preupdateType == 'reset' :
22632269 # --git-reset (preupdateType = 'reset')
22642270 print ('Restoring locally-updated GSAS-II files to original status' )
0 commit comments