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)