git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@382 830e0280-6d2a-0410-9c65-932aecc39d9d
Michal Ludvig authored on 2009/02/25 12:04:18... | ... |
@@ -1552,36 +1552,7 @@ def main(): |
1552 | 1552 |
error(u"S3 error: %s" % e) |
1553 | 1553 |
sys.exit(1) |
1554 | 1554 |
|
1555 |
-if __name__ == '__main__': |
|
1556 |
- try: |
|
1557 |
- ## Our modules |
|
1558 |
- ## Keep them in try/except block to |
|
1559 |
- ## detect any syntax errors in there |
|
1560 |
- from S3 import PkgInfo |
|
1561 |
- from S3.S3 import * |
|
1562 |
- from S3.Config import Config |
|
1563 |
- from S3.S3Uri import * |
|
1564 |
- from S3 import Utils |
|
1565 |
- from S3.Exceptions import * |
|
1566 |
- from S3.Utils import unicodise |
|
1567 |
- from S3.Progress import Progress |
|
1568 |
- from S3.CloudFront import Cmd as CfCmd |
|
1569 |
- |
|
1570 |
- main() |
|
1571 |
- sys.exit(0) |
|
1572 |
- |
|
1573 |
- except ParameterError, e: |
|
1574 |
- error(u"Parameter problem: %s" % e) |
|
1575 |
- sys.exit(1) |
|
1576 |
- |
|
1577 |
- except SystemExit, e: |
|
1578 |
- sys.exit(e.code) |
|
1579 |
- |
|
1580 |
- except KeyboardInterrupt: |
|
1581 |
- sys.stderr.write("See ya!\n") |
|
1582 |
- sys.exit(1) |
|
1583 |
- |
|
1584 |
- except Exception, e: |
|
1555 |
+def report_exception(e): |
|
1585 | 1556 |
sys.stderr.write(""" |
1586 | 1557 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1587 | 1558 |
An unexpected error has occurred. |
... | ... |
@@ -1598,15 +1569,16 @@ if __name__ == '__main__': |
1598 | 1598 |
sys.stderr.write("S3cmd: %s\n" % PkgInfo.version) |
1599 | 1599 |
except NameError: |
1600 | 1600 |
sys.stderr.write("S3cmd: unknown version. Module import problem?\n") |
1601 |
- sys.stderr.write("Python: %s\n" % sys.version.replace('\n', ' ')) |
|
1602 | 1601 |
sys.stderr.write("\n") |
1603 | 1602 |
sys.stderr.write(unicode(tb, errors="replace")) |
1603 |
+ |
|
1604 | 1604 |
if type(e) == ImportError: |
1605 | 1605 |
sys.stderr.write("\n") |
1606 | 1606 |
sys.stderr.write("Your sys.path contains these entries:\n") |
1607 | 1607 |
for path in sys.path: |
1608 | 1608 |
sys.stderr.write(u"\t%s\n" % path) |
1609 |
- sys.stderr.write("Now the question is where has S3/S3.py been installed?\n") |
|
1609 |
+ sys.stderr.write("Now the question is where have the s3cmd modules been installed?\n") |
|
1610 |
+ |
|
1610 | 1611 |
sys.stderr.write(""" |
1611 | 1612 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1612 | 1613 |
An unexpected error has occurred. |
... | ... |
@@ -1614,4 +1586,40 @@ if __name__ == '__main__': |
1614 | 1614 |
s3tools-bugs@lists.sourceforge.net |
1615 | 1615 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1616 | 1616 |
""") |
1617 |
+ |
|
1618 |
+if __name__ == '__main__': |
|
1619 |
+ try: |
|
1620 |
+ ## Our modules |
|
1621 |
+ ## Keep them in try/except block to |
|
1622 |
+ ## detect any syntax errors in there |
|
1623 |
+ from S3 import PkgInfo |
|
1624 |
+ from S3.S3 import * |
|
1625 |
+ from S3.Config import Config |
|
1626 |
+ from S3.S3Uri import * |
|
1627 |
+ from S3 import Utils |
|
1628 |
+ from S3.Exceptions import * |
|
1629 |
+ from S3.Utils import unicodise |
|
1630 |
+ from S3.Progress import Progress |
|
1631 |
+ from S3.CloudFront import Cmd as CfCmd |
|
1632 |
+ |
|
1633 |
+ main() |
|
1634 |
+ sys.exit(0) |
|
1635 |
+ |
|
1636 |
+ except ImportError, e: |
|
1637 |
+ report_exception(e) |
|
1638 |
+ sys.exit(1) |
|
1639 |
+ |
|
1640 |
+ except ParameterError, e: |
|
1641 |
+ error(u"Parameter problem: %s" % e) |
|
1642 |
+ sys.exit(1) |
|
1643 |
+ |
|
1644 |
+ except SystemExit, e: |
|
1645 |
+ sys.exit(e.code) |
|
1646 |
+ |
|
1647 |
+ except KeyboardInterrupt: |
|
1648 |
+ sys.stderr.write("See ya!\n") |
|
1649 |
+ sys.exit(1) |
|
1650 |
+ |
|
1651 |
+ except Exception, e: |
|
1652 |
+ report_exception(e) |
|
1617 | 1653 |
sys.exit(1) |