Stuck at "Update the disk name" when generating disk image

Bug #1911469 reported by Cubic PPA
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cubic
Fix Released
Medium
Cubic PPA

Bug Description

I am unable to create an ISO as it gets stuck at the "Update the disk name" stage. I am using version 2021.01.40

I have tested this on a clean project where nothing is added or changed. My source is an Ubuntu 20.04.1 live image.

The following is the output when running cubic in the terminal, (Only output for the relevant stage)

Update the disk name
  • The existing file will be updated...... /home/marlind/test_cubic/custom-
                                            disk/README.diskdefines
  • Update disk name....................... #define DISKNAME Ubuntu-Server
                                            20.04.1 2021.01.13 "Custom Focal
                                            Fossa"
  • Update disk note....................... #define DISKNOTE Generated using
                                            Cubic version 2021.01.40 on 13. jan.
                                            2021 kl. 13.55 +0100 based on
                                            ubuntu-20.04.1-live-server-amd64.iso

 Update the disk information
  • Reformat the time stamp................ 13. jan. 2021 kl. 13.55 +0100
  • Try old time stamp format.............. %x %X
  • Matched the time stamp format?......... No
  • The new time stamp format is........... %Y%m%d

Exception in thread Thread-11:
Traceback (most recent call last):
  File "/usr/share/cubic/pages/generate_page.py", line 730, in update_disk_info
    time_stamp = constructor.reformat_time_stamp(model.project.modify_date, TIME_STAMP_FORMAT_YYYYMMDD)
  File "/usr/share/cubic/utilities/constructor.py", line 228, in reformat_time_stamp
    time_stamp = time.strftime(new_format, struct_time).strip()
TypeError: Tuple or struct_time argument required

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/share/cubic/navigator.py", line 446, in navigate
    result = new_page.enter(action, page) if new_page else None
  File "/usr/share/cubic/pages/generate_page.py", line 170, in enter
    is_error = update_disk_name_and_disk_info()
  File "/usr/share/cubic/pages/generate_page.py", line 626, in update_disk_name_and_disk_info
    is_error = update_disk_info()
  File "/usr/share/cubic/pages/generate_page.py", line 738, in update_disk_info
    logger.log_value('Unable to update the disk information in', file_path)
UnboundLocalError: local variable 'file_path' referenced before assignment

Cubic PPA (cubic-wizard)
Changed in cubic:
assignee: nobody → Cubic PPA (cubic-wizard)
Cubic PPA (cubic-wizard)
Changed in cubic:
importance: Undecided → Medium
Revision history for this message
Cubic PPA (cubic-wizard) wrote :

An experiment demonstrating the issue.

Even though '%x %X' is used to format the time stamp, the resulting time stamp string can not be parsed using this same format.

$ sudo apt install language-pack-nb

$ python3.8

> import locale
> locale.setlocale(locale.LC_ALL, 'nb_NO.UTF-8')

  'nb_NO.UTF-8'

> import datetime
> time_stamp = datetime.datetime.now().strftime('%x %X')
> time_stamp

  '24. jan. 2021 kl. 19.48 '

> import time
> time.strptime(time_stamp, '%x %X')

  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/lib/python3.8/_strptime.py", line 562, in _strptime_time
      tt = _strptime(data_string, format)[0]
    File "/usr/lib/python3.8/_strptime.py", line 349, in _strptime
      raise ValueError("time data %r does not match format %r" %
  ValueError: time data '24. jan. 2021 kl. 19.48 ' does not match format '%x %X'

Revision history for this message
Cubic PPA (cubic-wizard) wrote :

Perhaps the best option is to be very explicit about the time format.

Instead to trying to intrepret the time format string based on locale, we should define it to be the same string for all locales. The drawback obviously is that date and time will not be displayed in a localized manner, which was preferable.

PEP does provides guidance in favor of this explicit approach: "In the face of ambiguity, refuse the temptation to guess." (https://www.python.org/dev/peps/pep-0020)

This approach will work well for new projects in all locales. However, for existing projects the create_date in the cubic.conf file will have the old format, and this will result in the same parsing issue in certain locales such as nb_NO.UTF-8. We could opt to simply not parse the create_date, since it never changes once a project is created. The modify_date is always overwritten and does not need to be parsed.

A reasonable format to use is "YYYY-MM-DD HH:MM" with HH in 24 hr format; we probably don't need to display seconds.

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    > import locale
    > locale.setlocale(locale.LC_ALL, 'nb_NO.UTF-8')
      'nb_NO.UTF-8'

    > import datetime
    > time_stamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
    > time_stamp
      '2021-01-24 22:36'

    > import time
    > struct_time = time.strptime(time_stamp, '%Y-%m-%d %H:%M')

    > time.strftime('%Y', struct_time)
      '2021'

    > time.strftime('%m', struct_time)
      '01'

    > time.strftime('%d', struct_time)
      '24'

    > time.strftime('%H:%M%S', struct_time)
      '22:3600'

    > time.strftime('%Y-%m-%d %H:%M', struct_time)
      '2021-01-24 22:36'
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Cubic PPA (cubic-wizard)
Changed in cubic:
status: New → In Progress
Revision history for this message
Cubic PPA (cubic-wizard) wrote :

Fix released in version 2021.01-41.

The date and time format is now explicitly set to "YYYY-MM-DD HH:MM" regardless of locale. HH is in 24 hour format. The create_date in cubic.conf will retain the original format. The modify_date in cubic.conf, and other places where date time is required, will use the new format.

Changed in cubic:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.