Verified Commit 690500df authored by Oskar Roesler's avatar Oskar Roesler
Browse files

Handle retry with rosdistro name prefix better in parser.py

parent 08f6978c
......@@ -13,14 +13,15 @@ class Routines:
CACHE_ROOT = os.environ.get("XDG_CACHE_HOME", os.path.join(Path.home(), ".cache/"))
def __init__(self, package=None, verbosity=False, output=True):
self.package = package
self.verbosity = verbosity
self.output = output
self.config_path = os.path.join(Routines.CONFIG_ROOT, 'ros-aur-helper')
self.cache_path = os.path.join(Routines.CACHE_ROOT, 'ros-aur-helper')
self.check_and_create_path(self.config_path)
self.check_and_create_path(self.cache_path)
self.repos_path = os.path.join(self.cache_path, "packages", self.package)
if package:
self.package = package
self.repos_path = os.path.join(self.cache_path, "packages", self.package)
config = self.get_config()
self.gh = Github(config['CI']['GH_OAUTH_TOKEN'])
self.gh_organization_name = config['CI']['GH_ORGANIZATION']
......
......@@ -30,16 +30,22 @@ def main(argv):
args = parser.parse_args(argv)
try:
commands(args.command, args.package, args.verbose, args.quiet)
except BaseException as e:
name = "{0}{1}".format(Routines.get_ros_distro(), args.package)
if os.path.exists(os.path.join("packages/", name)):
def retry_with_rosdistro_name():
name = "{0}{1}".format(Routines().get_ros_distro(), args.package)
if os.path.exists(os.path.join(Routines.CACHE_ROOT, "packages/", name)):
try:
commands(args.command, name, args.verbose, args.quiet)
except BaseException as e:
print(f"Error: {args.package} could not be found while running {args.command}")
except KeyError:
print(f"Error: {args.package} could not be found in ROS Metainfo dict while running {args.command}")
except FileNotFoundError:
print(f"Error: {args.package} folder could not be found while running {args.command}")
try:
commands(args.command, args.package, args.verbose, args.quiet)
except KeyError:
retry_with_rosdistro_name()
except FileNotFoundError:
retry_with_rosdistro_name()
if __name__=='__main__':
main(sys.argv)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment