Changeset 785:7fa99e74e8ab for src
- Timestamp:
- 06/16/16 17:43:30 (8 years ago)
- Branch:
- version_0.37_maint
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/update.py
r681 r785 10 10 import subprocess 11 11 import hashlib 12 import traceback 12 13 13 14 if os.name=="nt": … … 291 292 sum.update(path) 292 293 toremoveDir = getToremoveDir(toremoveDir, directory) 293 os.rename(path, os.path.join(toremoveDir, sum.hexdigest())) 294 targetPath = os.path.join(toremoveDir, sum.hexdigest()) 295 try: 296 os.remove(targetPath) 297 except: 298 pass 299 os.rename(path, targetPath) 294 300 except Exception, e: 295 301 print "Cannot remove file " + path + ": " + utf2unicode(str(e)) … … 372 378 listener.done() 373 379 except Exception, e: 380 exc = traceback.format_exc() 381 print >> sys.stderr, utf2unicode(exc) 382 374 383 error = utf2unicode(str(e)) 375 384 print >> sys.stderr, "Error:", error 385 376 386 listener.failed(error) 377 387 … … 521 531 def update(directory, updateURL, listener, fromGUI = False): 522 532 """Perform the update.""" 523 result = prepareUpdate(directory, updateURL, listener) 524 if result is None: 525 return 526 527 (manifest, updateManifest, modifiedAndNew, removed) = result 528 localRemoved = getToremoveFiles(directory) 529 530 if not modifiedAndNew and not removed and not localRemoved: 531 listener.done() 532 return 533 534 if fromGUI and not isDirectoryWritable(directory): 535 if listener.needSudo(): 536 sudoUpdate(directory, updateURL, listener, updateManifest) 537 else: 538 updateFiles(directory, updateURL, listener, updateManifest, 539 modifiedAndNew, removed, localRemoved) 533 try: 534 result = prepareUpdate(directory, updateURL, listener) 535 if result is None: 536 return 537 538 (manifest, updateManifest, modifiedAndNew, removed) = result 539 localRemoved = getToremoveFiles(directory) 540 541 if not modifiedAndNew and not removed and not localRemoved: 542 listener.done() 543 return 544 545 if fromGUI and not isDirectoryWritable(directory): 546 if listener.needSudo(): 547 sudoUpdate(directory, updateURL, listener, updateManifest) 548 else: 549 updateFiles(directory, updateURL, listener, updateManifest, 550 modifiedAndNew, removed, localRemoved) 551 except Exception, e: 552 exc = traceback.format_exc() 553 print >> sys.stderr, utf2unicode(exc) 554 555 error = utf2unicode(str(e)) 556 print >> sys.stderr, "Update error:", error 557 558 listener.failed(error) 540 559 541 560 #------------------------------------------------------------------------------ … … 543 562 def updateProcess(): 544 563 """This is called in the child process, when we need a child process.""" 545 clientSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 546 clientSocket.connect(("127.0.0.1", int(sys.argv[1]))) 547 548 directory = os.path.dirname(sys.argv[0]) 549 550 manifest = readLocalManifest(directory) 551 552 updateManifest = Manifest() 553 with open(sys.argv[2], "rt") as f: 554 updateManifest.readFrom(f) 555 556 (modifiedAndNew, removed) = manifest.compare(updateManifest) 557 localRemoved = getToremoveFiles(directory) 558 559 updateFiles(directory, sys.argv[3], 560 ClientListener(clientSocket), 561 updateManifest, modifiedAndNew, removed, localRemoved) 564 try: 565 clientSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 566 clientSocket.connect(("127.0.0.1", int(sys.argv[1]))) 567 568 directory = os.path.dirname(sys.argv[0]) 569 570 manifest = readLocalManifest(directory) 571 572 updateManifest = Manifest() 573 with open(sys.argv[2], "rt") as f: 574 updateManifest.readFrom(f) 575 576 (modifiedAndNew, removed) = manifest.compare(updateManifest) 577 localRemoved = getToremoveFiles(directory) 578 579 updateFiles(directory, sys.argv[3], 580 ClientListener(clientSocket), 581 updateManifest, modifiedAndNew, removed, localRemoved) 582 except: 583 exc = traceback.format_exc() 584 print >> sys.stderr, utf2unicode(exc) 562 585 563 586 #------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.