@@ -2031,10 +2031,11 @@ def openInNewTerm(project=None,g2script=None,pythonapp=sys.executable):
2031
2031
2032
2032
if __name__ == '__main__' :
2033
2033
'''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.
2035
2037
'''
2036
2038
# check what type of update is being called for
2037
- import git
2038
2039
gitUpdate = False
2039
2040
preupdateType = None
2040
2041
updateType = None
@@ -2096,6 +2097,11 @@ def openInNewTerm(project=None,g2script=None,pythonapp=sys.executable):
2096
2097
print ('invalid form for --git-regress' )
2097
2098
help = True
2098
2099
break
2100
+ try :
2101
+ import git
2102
+ except :
2103
+ print ('Import of git failed for --git-regress' )
2104
+ sys .exit ()
2099
2105
gitversion = argsplit [1 ]
2100
2106
# make sure the version or tag supplied is valid and convert to
2101
2107
# a full sha hash
@@ -2242,23 +2248,23 @@ def openInNewTerm(project=None,g2script=None,pythonapp=sys.executable):
2242
2248
fp .close ()
2243
2249
sys .exit ()
2244
2250
2251
+ try :
2252
+ import git
2253
+ except :
2254
+ print (f'Import of git failed. { updateType } update mode { preupdateType } ' )
2255
+ sys .exit ()
2256
+
2245
2257
if gitUpdate :
2246
2258
import time
2247
2259
time .sleep (1 ) # delay to give the main process a chance to exit
2248
2260
# so we don't change code for a running process
2249
2261
# 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' )
2262
2268
if preupdateType == 'reset' :
2263
2269
# --git-reset (preupdateType = 'reset')
2264
2270
print ('Restoring locally-updated GSAS-II files to original status' )
0 commit comments