Changeset 3954


Ignore:
Timestamp:
May 4, 2019 7:06:35 AM (4 years ago)
Author:
toby
Message:

add cleanup if svn error for svn switch & update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpath.py

    r3776 r3954  
    359359    return changed
    360360
     361def svnCleanup(fpath=os.path.split(__file__)[0],verbose=True):
     362    '''This runs svn cleanup on a selected local directory.
     363
     364    :param str fpath: path to repository dictionary, defaults to directory where
     365       the current file is located
     366    '''
     367    svn = whichsvn()
     368    if not svn: return
     369    if verbose: print(u"Performing svn cleanup at "+fpath)
     370    cmd = [svn,'cleanup',fpath]
     371    if verbose:
     372        s = 'subversion command:\n  '
     373        for i in cmd: s += i + ' '
     374        print(s)
     375    s = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
     376    out,err = MakeByte2str(s.communicate())
     377    if err:
     378        print(60*"=")
     379        print("****** An error was noted, see below *********")
     380        print(60*"=")
     381        print(err)
     382        s = '\nsvn command:  '
     383        for i in cmd: s += i + ' '
     384        print(s)
     385        #raise Exception('svn cleanup failed')
     386        return False
     387    elif verbose:
     388        print(out)
     389    return True
     390       
    361391def svnUpdateDir(fpath=os.path.split(__file__)[0],version=None,verbose=True):
    362392    '''This performs an update of the files in a local directory from a server.
     
    396426        for i in cmd: s += i + ' '
    397427        print(s)
    398         sys.exit()
     428        if svnCleanup(fpath):
     429            s = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
     430            out,err = MakeByte2str(s.communicate())
     431            if err:
     432                print(60*"=")
     433                print("****** Drat, failed again: *********")
     434                print(60*"=")
     435                print(err)
     436            else:
     437                return
     438        raise Exception('svn update failed')
    399439    elif verbose:
    400440        print(out)
     
    476516        for i in cmd: s += i + ' '
    477517        print(s)
     518        if svnCleanup(fpath):
     519            s = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
     520            out,err = MakeByte2str(s.communicate())
     521            if err:
     522                print(60*"=")
     523                print("****** Drat, failed again: *********")
     524                print(60*"=")
     525                print(err)
     526            else:
     527                return True
    478528        return False
    479529    if verbose:
Note: See TracChangeset for help on using the changeset viewer.