def _run_fisheye(self, options, args): mode = 'check' prefix, name = __parse_prefix_name(args[0]) if len(args) > 1: mode = args[1].lower() if not mode in ('on', 'off', 'check'): raise CommandArgumentError('fisheye: Enter either on or off.') repo = __load_repository_from_yaml(prefix, name) fisheye_admin = FisheyeAdmin(config.FISHEYE_ADMIN_PW) if mode == 'on': if repo.fisheye == True: print 'Fisheye is already turned on for %s.' % repo.name return else: repo.fisheye = True repo.set_fisheye_auth_path() if fisheye_admin.create_repository(repo, __get_description()): print "Successfully create a fisheye instance for %s" % repo.name else: print "Failed to create a fisheye instance for %s. Please do it by hand." % repo.name commit_message = 'Turned fisheye ON for %s.' % name elif mode == "off": if repo.fisheye == False: print 'Fisheye is already turned off for %s.' % repo.name return else: repo.fisheye = False if fisheye_admin.delete_repository(repo): print "Successfully deleted the fisheye instance for %s" % repo.name else: print "Failed to delete the fisheye instance for %s. Please do it by hand." % repo.name commit_message = 'Turned fisheye OFF for %s.' % name else: print 'Fisheye is %s for %s' % (repo.fisheye and 'ON' or 'OFF', repo.name) return __write_repository_yaml(repo) __checkin_yaml(repo, commit_message) if repo.fisheye: __write_repository_fisheyeauth(repo) else: try: os.remove(repo.fisheye_auth_path) except Exception, e: raise CommandError('Error removing fisheye auth file at: %s \n%s' % (repo.fisheye_auth_path, e) )
def _run_create(self, options, args): """ Create the repository. Save the yaml descriptor. """ prefix, name = __parse_prefix_name(args[0]) print "Name = %s" % name if prefix: print "Prefix = %s" % prefix print "Fisheye = %s" % options.fisheye repo = Repository(prefix, name, options.fisheye) if Repository.exists(repo.path_to_repo): raise CommandError('A repository named "%s" already exists.' % repo.path) try: __check_path_dir(repo) print 'Creating the repository ...' repo.create() print 'Created the repository' print repo.apache_conf apache_conf.process_to_file(repo.apache_conf, {'repopath' : repo.path, 'users' : ', '.join(repo.users()), 'apache_authz_path' : repo.apache_authz}) print "Created apache conf" __write_repository_yaml(repo) print "CREATED repository at %s." % repo.path if options.fisheye: __write_repository_fisheyeauth(repo) fisheye_admin = FisheyeAdmin(password=config.FISHEYE_ADMIN_PW) if fisheye_admin.create_repository(repo, __get_description()): print "Successfully created a fisheye instance for %s" % repo.name except Exception, e: raise CommandError("Failed to create the repository at %s\n" % repo.path_to_repo, "The original error was: %s: %s" % (type(e), e))