J'ai rencontré une erreur en essayant d'utiliser « Outils personnalisation » > « Admin » > « Show Project Plan HTML » sur PT9.0 dans Wasta-Linux. Il s'avère que le script Python tente d'utiliser le Registre Windows pour trouver le dossier des projets Paratext. Notez la 3e ligne, « from _winreg import… » (depuis cms/ProjectPlanImport.py) :
def settingsDirectory():
# Find the directory with Paratext 8 projects using the windows registry
from _winreg import OpenKey, EnumValue, HKEY_LOCAL_MACHINE
strPath = r"SOFTWARE\WOW6432Node\Paratext\8"
try:
aKey = OpenKey(HKEY_LOCAL_MACHINE, strPath)
for i in [0,1,2,3,4,5]:
aName, aValue, irrelevant = EnumValue(aKey,i)
if aName == 'Settings_Directory':
return aValue + '\\'
return None
except WindowsError:
# The registry key was not found
return None
except:
raise
Cependant, ce même dossier peut être trouvé de manière relative en utilisant le module os.path. J'ai donc mis à jour la fonction sur mon système comme suit :
def settingsDirectory():
# Find the directory with Paratext 8 projects using Python 2 tools.
cms_dir = os.path.dirname(os.path.realpath(__file__))
if os.path.basename(cms_dir) == 'cms' and os.path.isdir(cms_dir):
return os.path.dirname(cms_dir)
else:
return None
Je suppose donc que ma question est la suivante : est-il possible qu'avec une installation non standard , le dossier cms se trouve ailleurs que dans le dossier des projets Paratext, ce qui nécessiterait la vérification du registre sous Windows ? Sinon, quelqu'un envisagerait-il de mettre à jour les scripts ProjectPlanImport.py et ProjectPlanRoot.py pour utiliser les outils intégrés afin de rendre les scripts plus universellement compatibles ?
Je serais également disposé à trouver un moyen d'effectuer une vérification du système d'exploitation et de gérer la recherche de settingsDirectory de manière dépendante du système d'exploitation si je pouvais en discuter avec la bonne personne. Au fait, il semble que ce soient les seuls deux endroits où le module _winreg est référencé dans les scripts cms.
I got an error trying to use “Outils personnalisation” > “Admin” > “Show Project Plan HTML” on PT9.0 in Wasta-Linux. It turns out the python script attempts to use the Windows Registry to find the Paratext Projects folder. Note the 3rd line, “from _winreg import…” (from cms/ProjectPlanImport.py):
def settingsDirectory():
# Find the directory with Paratext 8 projects using the windows registry
from _winreg import OpenKey, EnumValue, HKEY_LOCAL_MACHINE
strPath = r"SOFTWARE\WOW6432Node\Paratext\8"
try:
aKey = OpenKey(HKEY_LOCAL_MACHINE, strPath)
for i in [0,1,2,3,4,5]:
aName, aValue, irrelevant = EnumValue(aKey,i)
if aName == 'Settings_Directory':
return aValue + '\\'
return None
except WindowsError:
# The registry key was not found
return None
except:
raise
However, this same folder can be found in a relative fashion using the os.path module. So I updated the function on my system to the following:
def settingsDirectory():
# Find the directory with Paratext 8 projects using Python 2 tools.
cms_dir = os.path.dirname(os.path.realpath(__file__))
if os.path.basename(cms_dir) == 'cms' and os.path.isdir(cms_dir):
return os.path.dirname(cms_dir)
else:
return None
So I guess my question is: Is it possible that in a non-standard install the cms folder could be located somewhere other than within the Paratext Projects folder, which would necessitate the registry check in Windows? Or, if not, would someone consider updating the ProjectPlanImport.py and ProjectPlanRoot.py scripts to use the built-in tools to make the scripts more universally compatible?
I’d also be willing to work out a way to do an OS check and handle finding the settingsDirectory in an OS-dependent way if I could discuss this with the right person. By the way, these seem to be the only two places that the _winreg module is referenced in the cms scripts.
Traduit automatiquement depuis English Afficher l'original