def join_and_leave(proj_id, user, repeat, prefix=""): user_id = user.id if prefix: prefix += ' ' for i in range(repeat): try: now = datetime.datetime.now() logger.info('%s%s: user %s joining project %s' % (prefix, now, user_id, proj_id)) membership = join(proj_id, user) except ProjectError as e: logger.info(e.message) continue except Exception as e: logger.exception(e) continue try: now = datetime.datetime.now() logger.info('%s%s: user %s leaving project %s' % (prefix, now, user_id, proj_id)) leave(membership.id, user) except ProjectError as e: logger.info(e.message) except Exception as e: logger.exception(e)
def join_and_leave(proj_id, user_id, repeat, prefix=""): if prefix: prefix += ' ' for i in range(repeat): try: now = datetime.datetime.now() logger.info('%s%s: user %s joining project %s' % (prefix, now, user_id, proj_id)) join(proj_id, user_id) except PermissionDenied as e: logger.info('Membership already exists') except Exception as e: logger.exception(e) try: now = datetime.datetime.now() logger.info('%s%s: user %s leaving project %s' % (prefix, now, user_id, proj_id)) leave(proj_id, user_id) except IOError as e: logger.info('No such membership') except Exception as e: logger.exception(e)
def main(self): if self.args.get('init') or not os.path.exists(self.vars['pathDB']): db_init.init(self.vars['pathDB']) if not self.args.get('user'): sys.stderr.write('[WARN] Please input user name\n') sys.exit(0) views.init(self.vars['pathDB']) ## check user user = views.ckUser(self.args['user']) if not user: views.leave() #views.conf['user'] = user ## start countLoop = 0 while countLoop < 3: views.showItem() strFunc = input( "input item id | Edit ShopCart(s) | Checkout(c) | checkOrders(l) | Quit(q): " ) if strFunc == 'q': views.leave() elif strFunc == 's': views.eCart_enter() countLoop = 0 elif strFunc == 'c': views.checkout() countLoop = 0 elif strFunc == 'l': views.showOrders(user) countLoop = 0 elif strFunc.isdigit(): views.addItem(int(strFunc)) countLoop = 0 else: countLoop += 1 sys.stderr.write('[WARN] Error Operation more than 3 times!!\n') views.leave()