Changeset 788:805d2ae4d025 for src/mlx
- Timestamp:
- 06/16/16 17:43:30 (8 years ago)
- Branch:
- default
- Phase:
- public
- transplant_source:
- ©tè««ÿ8GÅâô£-!sG
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/update.py
r781 r788 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)) … … 386 392 listener.done() 387 393 except Exception, e: 394 exc = traceback.format_exc() 395 print >> sys.stderr, utf2unicode(exc) 396 388 397 error = utf2unicode(str(e)) 389 398 print >> sys.stderr, "Error:", error 399 390 400 listener.failed(error) 391 401 … … 535 545 def update(directory, updateURL, listener, fromGUI = False): 536 546 """Perform the update.""" 537 result = prepareUpdate(directory, updateURL, listener) 538 if result is None: 539 return 540 541 (manifest, updateManifest, modifiedAndNew, removed) = result 542 localRemoved = getToremoveFiles(directory) 543 544 if not modifiedAndNew and not removed and not localRemoved: 545 listener.done() 546 return 547 548 if fromGUI and not isDirectoryWritable(directory): 549 if listener.needSudo(): 550 sudoUpdate(directory, updateURL, listener, updateManifest) 551 else: 552 updateFiles(directory, updateURL, listener, updateManifest, 553 modifiedAndNew, removed, localRemoved) 547 try: 548 result = prepareUpdate(directory, updateURL, listener) 549 if result is None: 550 return 551 552 (manifest, updateManifest, modifiedAndNew, removed) = result 553 localRemoved = getToremoveFiles(directory) 554 555 if not modifiedAndNew and not removed and not localRemoved: 556 listener.done() 557 return 558 559 if fromGUI and not isDirectoryWritable(directory): 560 if listener.needSudo(): 561 sudoUpdate(directory, updateURL, listener, updateManifest) 562 else: 563 updateFiles(directory, updateURL, listener, updateManifest, 564 modifiedAndNew, removed, localRemoved) 565 except Exception, e: 566 exc = traceback.format_exc() 567 print >> sys.stderr, utf2unicode(exc) 568 569 error = utf2unicode(str(e)) 570 print >> sys.stderr, "Update error:", error 571 572 listener.failed(error) 554 573 555 574 #------------------------------------------------------------------------------ … … 557 576 def updateProcess(): 558 577 """This is called in the child process, when we need a child process.""" 559 clientSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 560 clientSocket.connect(("127.0.0.1", int(sys.argv[1]))) 561 562 directory = os.path.dirname(sys.argv[0]) 563 564 manifest = readLocalManifest(directory) 565 566 updateManifest = Manifest() 567 with open(sys.argv[2], "rt") as f: 568 updateManifest.readFrom(f) 569 570 (modifiedAndNew, removed) = manifest.compare(updateManifest) 571 localRemoved = getToremoveFiles(directory) 572 573 updateFiles(directory, sys.argv[3], 574 ClientListener(clientSocket), 575 updateManifest, modifiedAndNew, removed, localRemoved) 578 try: 579 clientSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 580 clientSocket.connect(("127.0.0.1", int(sys.argv[1]))) 581 582 directory = os.path.dirname(sys.argv[0]) 583 584 manifest = readLocalManifest(directory) 585 586 updateManifest = Manifest() 587 with open(sys.argv[2], "rt") as f: 588 updateManifest.readFrom(f) 589 590 (modifiedAndNew, removed) = manifest.compare(updateManifest) 591 localRemoved = getToremoveFiles(directory) 592 593 updateFiles(directory, sys.argv[3], 594 ClientListener(clientSocket), 595 updateManifest, modifiedAndNew, removed, localRemoved) 596 except: 597 exc = traceback.format_exc() 598 print >> sys.stderr, utf2unicode(exc) 576 599 577 600 #------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.