- Timestamp:
- Jan 11, 2007, 2:38:03 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/util.py
r4168 r4170 534 534 fid.write(stuff) 535 535 536 def get_ version_info():537 """ getsthe version number of the SVN536 def get_revision_number(): 537 """Get the version number of the SVN 538 538 NOTE: This requires that the command svn is on the system PATH 539 539 (simply aliasing svn to the binary will not work) 540 540 """ 541 541 542 # Create dummy info 543 #info = 'Revision: Version info could not be obtained.' 544 #info += 'A command line version of svn must be availbable ' 545 #info += 'on the system PATH, access to the subversion ' 546 #info += 'repository is necessary and the output must ' 547 #info += 'contain a line starting with "Revision:"' 548 549 542 550 #FIXME (Ole): Change this so that svn info is attempted first. 543 551 # If that fails, try to read a stored file with that same info (this would be created by e.g. the release script). Failing that, throw an exception. 544 552 545 546 import os, sys 547 548 # Create dummy info 549 info = 'Revision: Version info could not be obtained.' 550 info += 'A command line version of svn must be availbable ' 551 info += 'on the system PATH, access to the subversion ' 552 info += 'repository is necessary and the output must ' 553 info += 'contain a line starting with "Revision:"' 553 #FIXME (Ole): Move this and store_version_info to utilities 554 555 556 try: 557 from anuga.stored_version_info import version_info 558 except: 559 560 # No file available - try using Subversion 561 try: 562 fid = os.popen('svn info') 563 except: 564 msg = 'No version info stored and command "svn" is not ' 565 msg += 'recognised on the system PATH. What do you want me to do?' 566 raise Exception(msg) 567 else: 568 #print 'Got version from svn' 569 version_info = fid.read() 570 else: 571 pass 572 #print 'Got version from file' 573 574 575 for line in version_info.split('\n'): 576 if line.startswith('Revision:'): 577 break 578 579 fields = line.split(':') 580 msg = 'Keyword "Revision" was not found anywhere in text: %s' %version_info 581 assert fields[0].startswith('Revision'), msg 582 583 try: 584 revision_number = int(fields[1]) 585 except: 586 msg = 'Revision number must be an integer. I got %s' %fields[1] 587 msg += 'Check that the command svn is on the system path' 588 raise Exception(msg) 589 590 return revision_number 591 592 593 def store_version_info(destination_path='.', verbose=False): 594 """Obtain current version from Subversion and store it. 595 596 Title: store_version_info() 597 598 Author: Ole Nielsen (Ole.Nielsen@ga.gov.au) 599 600 CreationDate: January 2006 601 602 Description: 603 This function obtains current version from Subversion and stores it 604 is a Python file named 'stored_version_info.py' for use with 605 get_version_info() 606 607 If svn is not available on the system PATH, an Exception is thrown 608 """ 609 610 # Note (Ole): This function should not be unit tested as it will only 611 # work when running out of the sandpit. End users downloading the 612 # ANUGA distribution would see a failure. 613 # 614 # FIXME: This function should really only be used by developers ( 615 # (e.g. for creating new ANUGA releases), so maybe it should move 616 # to somewhere else. 617 618 import config 554 619 555 620 try: 556 621 fid = os.popen('svn info') 557 622 except: 558 msg = ' svnis not recognised on the system PATH'559 warn(msg, UserWarning)623 msg = 'Command "svn" is not recognised on the system PATH' 624 raise Exception(msg) 560 625 else: 561 lines = fid.readlines()626 txt = fid.read() 562 627 fid.close() 563 for line in lines: 564 if line.startswith('Revision:'): 565 info = line 566 break 567 568 return info 628 629 630 # Determine absolute filename 631 if destination_path[-1] != os.sep: 632 destination_path += os.sep 633 634 filename = destination_path + config.version_filename 635 636 fid = open(filename, 'w') 637 638 docstring = 'Stored version info.\n\n' 639 docstring += 'This file provides the version for distributions ' 640 docstring += 'that are not accessing Subversion directly.\n' 641 docstring += 'The file is automatically generated and should not ' 642 docstring += 'be modified manually.\n' 643 fid.write('"""%s"""\n\n' %docstring) 644 645 fid.write('version_info = """\n%s"""' %txt) 646 fid.close() 647 648 649 if verbose is True: 650 print 'Version info stored to %s' %filename 651 569 652 570 653 def sww2timeseries(swwfiles,
Note: See TracChangeset
for help on using the changeset viewer.