Skip to content

I need more details about the arguments

I don't understand the usage of the arguments. If I call the script with argument -h I get

$ python clone_issues.py -h
usage: clone_issues.py [-h] [--yes] [--create-users] [--clone-checklists] [--rebuild-issue-tree] [--map-custom-fields MAP_CUSTOM_FIELDS] [--map-statuses MAP_STATUSES] [--ignore-custom-fields IGNORE_CUSTOM_FIELDS]
                       project_name tracker_name [target_project_name] [target_tracker_name]

Clone issues from database source to target while keeping as much information as possible (especially author, creation timestamp, journal entries)

positional arguments:
  project_name
  tracker_name
  target_project_name   (optional) place issues in the project name
  target_tracker_name   (optional) place issues in the tracker name
...

Therefore I would expect that I can provide four arguments project-name, tracker-name, target-project-name and target-tracker-name. However, if I for instance call

$ python clone_issues.py --yes --rebuild-issue-tree Text1 Aufgaben Text2 Text3 1>attachment_copy_shell_commands.log
usage: clone_issues.py [-h] [--yes] [--create-users] [--clone-checklists] [--rebuild-issue-tree] [--map-custom-fields MAP_CUSTOM_FIELDS] [--map-statuses MAP_STATUSES] [--ignore-custom-fields IGNORE_CUSTOM_FIELDS]
                       project_name tracker_name [target_project_name] [target_tracker_name]
clone_issues.py: error: unrecognized arguments: Text3

How can I provide the fourth argument?

Additionally, it seems that only the second argument (in my case Aufgaben) is used. It does not matter what I provide as first (Text1) or third (Text2) argument, I always get the same result (in my case nothing is transferred to the target databsae). Aufgaben is the name of the project in the target database. If I provide a string here that does not exist as project in the target database, then I get an error message. Regardless whether I provide as first argument a project name that exists in the source database or not, just nothing will be copied.

Could you please explain the usage of the arguments? In my case I have two Redmine 4.2.3 instances. In the source system I have a project called Aufgaben with the three default trackers. It contains a sub-project that also must be copied. I want to transfer this contents to the target system. I have already crated an empty project Aufgaben there. I expect the following call:

$ python clone_issues.py --yes --rebuild-issue-tree Aufgaben Fehler Aufgaben Fehler 1>attachment_copy_shell_commands.log
usage: clone_issues.py [-h] [--yes] [--create-users] [--clone-checklists] [--rebuild-issue-tree] [--map-custom-fields MAP_CUSTOM_FIELDS] [--map-statuses MAP_STATUSES] [--ignore-custom-fields IGNORE_CUSTOM_FIELDS]
                       project_name tracker_name [target_project_name] [target_tracker_name]
clone_issues.py: error: unrecognized arguments: Fehler

which does not work (as explained above). If I remove the fourth argument I get

$ python clone_issues.py --yes --rebuild-issue-tree Aufgaben Fehler Aufgaben 1>attachment_copy_shell_commands.log
Traceback (most recent call last):
  File "/home/hain/src/redmine-migration/redmine/migration.py", line 270, in must_get
    return model.objects.using(database).get(**{field_name: field_value})
  File "/home/hain/src/redmine-migration/venv/lib/python3.9/site-packages/django/db/models/query.py", line 429, in get
    raise self.model.DoesNotExist(
redmine_models.models.DoesNotExist: Project matching query does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/hain/src/redmine-migration/redmine/clone_issues.py", line 13, in <module>
    RedmineMigration(sys.argv)
  File "/home/hain/src/redmine-migration/redmine/migration.py", line 30, in __init__
    self.handle(None, **vars(self.parser.parse_args(argv)))
  File "/usr/lib/python3.9/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/home/hain/src/redmine-migration/redmine/migration.py", line 316, in handle
    self.must_get(Project, 'name', options['target_project_name'])
  File "/home/hain/src/redmine-migration/redmine/migration.py", line 272, in must_get
    raise Exception("Could not find a %s where %s is %s in database %s" % (model.__name__, field_name, field_value, database))
Exception: Could not find a Project where name is Fehler in database target

If the second argument is a tracker name, then why do I get the error message that there is no project name Fehler?

BR, Udo