Subversion Repositories SmartDukaan

Rev

Rev 2246 | Rev 2277 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2246 Rev 2247
Line 2... Line 2...
2
 
2
 
3
import optparse
3
import optparse
4
import sys
4
import sys
5
 
5
 
6
from thrift.Thrift import TException
6
from thrift.Thrift import TException
-
 
7
import traceback
7
 
8
 
8
if __name__ == '__main__' and __package__ is None:
9
if __name__ == '__main__' and __package__ is None:
9
    import os
10
    import os
10
    sys.path.insert(0, os.getcwd())
11
    sys.path.insert(0, os.getcwd())
11
 
12
 
Line 31... Line 32...
31
    
32
    
32
    try:
33
    try:
33
        userServiceClient.get_client().resetCart(transaction.shopping_cart_id, items);
34
        userServiceClient.get_client().resetCart(transaction.shopping_cart_id, items);
34
    except ShoppingCartException, TException:
35
    except ShoppingCartException, TException:
35
        print "Error while resetting the cart in the cart database"
36
        print "Error while resetting the cart in the cart database"
36
        print sys.exc_info()[2]
37
        traceback.print_exc()
37
    except:
38
    except:
38
        print "Unexpected exception"
39
        print "Unexpected exception"
39
        print sys.exc_info()[2]
40
        traceback.print_exc()
40
 
41
 
41
def track_coupon_usage(transaction, userServiceClient):
42
def track_coupon_usage(transaction, userServiceClient):
42
    try:
43
    try:
43
        cart = userServiceClient.get_client().getCart(transaction.shopping_cart_id)
44
        cart = userServiceClient.get_client().getCart(transaction.shopping_cart_id)
44
        coupon_code = cart.couponCode
45
        coupon_code = cart.couponCode
45
        
46
        
46
        if coupon_code is not None and coupon_code != '':
47
        if coupon_code is not None and coupon_code != '':
47
            PromotionClient().get_client().trackCouponUsage(coupon_code, transaction.id, transaction.customer_id);
48
            PromotionClient().get_client().trackCouponUsage(coupon_code, transaction.id, transaction.customer_id);
48
    except ShoppingCartException:
49
    except ShoppingCartException:
49
        print "Error occurred in reading CardId for transaction"
50
        print "Error occurred in reading CardId for transaction"
50
        print sys.exc_info()[2]
51
        traceback.print_exc()
51
    except PromotionException:
52
    except PromotionException:
52
        print "Promotion Exception: "
53
        print "Promotion Exception: "
53
        print sys.exc_info()[2]
54
        traceback.print_exc()
54
    except TException:
55
    except TException:
55
        print "Transport from Promotion Service failed:"
56
        print "Transport from Promotion Service failed:"
56
        print sys.exc_info()[2]
57
        traceback.print_exc()
57
    except Exception:
58
    except Exception:
58
        print "Unexpected exception:"
59
        print "Unexpected exception:"
59
        print sys.exc_info()[2]
60
        traceback.print_exc()
60
 
61
 
61
def main():
62
def main():
62
    parser = optparse.OptionParser()
63
    parser = optparse.OptionParser()
63
    parser.add_option("-t", "--txn-id", dest="txn_id",
64
    parser.add_option("-t", "--txn-id", dest="txn_id",
64
                   type="int",
65
                   type="int",