Skip to content
This repository was archived by the owner on Oct 1, 2025. It is now read-only.
This repository was archived by the owner on Oct 1, 2025. It is now read-only.

corrupted or non-auto-generated *_repy.py files cause softwareupdater to fail to start #5

@choksi81

Description

@choksi81

Using repyhelper.translate_and_import will throw a !TranslationError (see below) if the *_repy.py file of a module it is trying to import appears to not be auto-generated. It does this to prevent the chance of clobbering a file that isn't actually a _repy.py file generated from a .repy file.

However, if for any reason one of the repy files that the software updater depends on doesn't appear to be auto-generated, it will crash when it starts due to a !TranslationError.

So, the concern is along the lines of: what if the file should actually be overwritten because it's bogus? Maybe the user's disk was full the last time it tried to be auto-generated and an empty file was written, or the system crashed or process was killed while it was generating the file?

There is also risk of programmer error. What if the tag line used to identify auto-generated files was changed and all of the testing was done with clean installers rather than updates? Seems unlikely not to be noticed, but if it happened it could knock out every node that updated. (Similarly, had the _repy.py files accidentally pushed with 0.1j (#529) not had the correct tag line, it would have knocked out every node that updated due to the !TranslationError.)

So, there's probably risk of accidental clobbering, but it might be worth considering removing the auto-generated check from repyhelper. For that matter, it might be worth considering allowing use of a _repy.py file even if there is no corresponding .repy rather than throw a !TranslationError in that case, as well.

It's worth noting that it's not just a software updater issue. This same issue would cause the nodemanager to refuse to start. However, that seems less risky than if the software updater refused to start because the software updater not running would make it impossible to correct the issue.

~/downloads/seattle_repy$ python softwareupdater.py                                                  
Traceback (most recent call last):                                                                                
  File "softwareupdater.py", line 41, in <module>                                                                 
    repyhelper.translate_and_import("signeddata.repy")                                                            
  File "/home/justin/downloads/seattle_repy/repyhelper.py", line 291, in translate_and_import                     
    _import_file_contents_to_caller_namespace(modulename, preserve_globals)                                       
  File "/home/justin/downloads/seattle_repy/repyhelper.py", line 321, in _import_file_contents_to_caller_namespace
    import_module = __import__(modulename)                                                                        
  File "/home/justin/downloads/seattle_repy/signeddata_repy.py", line 50, in <module>                             
    repyhelper.translate_and_import('rsa.repy')                                                                   
  File "/home/justin/downloads/seattle_repy/repyhelper.py", line 291, in translate_and_import                     
    _import_file_contents_to_caller_namespace(modulename, preserve_globals)                                       
  File "/home/justin/downloads/seattle_repy/repyhelper.py", line 321, in _import_file_contents_to_caller_namespace
    import_module = __import__(modulename)                                                                        
  File "/home/justin/downloads/seattle_repy/rsa_repy.py", line 41, in <module>                                    
    repyhelper.translate_and_import('pycryptorsa.repy')
  File "/home/justin/downloads/seattle_repy/repyhelper.py", line 290, in translate_and_import
    modulename = translate(filename, shared_mycontext, callfunc, callargs, force_overwrite)
  File "/home/justin/downloads/seattle_repy/repyhelper.py", line 241, in translate
    if force_overwrite or _translation_is_needed(filename, generatedfilename):
  File "/home/justin/downloads/seattle_repy/repyhelper.py", line 110, in _translation_is_needed
    raise TranslationError("File name exists but wasn't automatically generated: " + generatedfile)
repyhelper.TranslationError: File name exists but wasn't automatically generated: pycryptorsa_repy.py

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions