i become this error message, if i click on Software Update.
Traceback (most recent call last):
File “/opt/rockstor/src/rockstor/storageadmin/views/command.py”, line 177, in post
return Response(update_check(subscription=subo))
File “/opt/rockstor/src/rockstor/system/pkg_mgmt.py”, line 154, in update_check
version, date = rpm_build_info(pkg)
File “/opt/rockstor/src/rockstor/system/pkg_mgmt.py”, line 99, in rpm_build_info
bdate = datetime.strptime(dstr, ‘%a %d %b %Y’)
File “/usr/lib64/python2.7/_strptime.py”, line 325, in _strptime
(data_string, format))
ValueError: time data ‘Mo 20 Jun 2016’ does not match format ‘%a %d %b %Y’
I'm not familar with Phyton or other programming languages.
And there are more error messages like this. I can’t add members, disks, pools or shares.
Hmm, this is a localisation issue. It seems that we need to import the user’s system locale settings somewhere before handling strings like these. @suman/@Flyer/@phillxnet, what would be the best place to put this?
At first GUI-Start this error messagebox comes after click on submit:
Traceback (most recent call last):
File “/opt/rockstor/src/rockstor/rest_framework_custom/generic_view.py”, line 40, in _handle_exception
yield
File “/opt/rockstor/src/rockstor/storageadmin/views/disk.py”, line 245, in post
return self._update_disk_state()
File “/opt/rockstor/eggs/Django-1.6.11-py2.7.egg/django/db/transaction.py”, line 371, in inner
return func(*args, **kwargs)
File “/opt/rockstor/src/rockstor/storageadmin/views/disk.py”, line 62, in _update_disk_state
disks = scan_disks(settings.MIN_DISK_SIZE)
File “/opt/rockstor/src/rockstor/fs/btrfs.py”, line 1052, in scan_disks
dmap[‘SIZE’] = int(float(size_str[:-1]) * 1024 * 1024)
ValueError: invalid literal for float(): 225,5
Hi @Uwe_Ganswig, asking one last test:
can you provide output from shell locale cmd ? thanks
Why am I asking this?? Had some testing on a python shell on Rockstor dev machine with this code and all was fine, returning expected 2016-Jun-21 (repeated same experiment with locale it_IT.utf8 and right italian date format and it was fine too)
from datetime import (datetime, timedelta)
import locale
locale.setlocale(locale.LC_ALL, 'de_DE.utf8')
print(locale.getlocale())
l = 'Build Date : Mo 20 Jun 2016 02:46:10 CEST'
dfields = l.strip().split()
dstr = ' '.join(dfields[3:7])
print(dstr)
bdate = datetime.strptime(dstr, '%a %d %b %Y')
print(bdate)
bdate += timedelta(days=1)
print(bdate)
date = bdate.strftime('%Y-%b-%d')
print(date)
Hi @Uwe_Ganswig & @sfranzen too, finally got it
There’s a bug in python not reading current locale.
Having not all Rockstor users german locale we can’t setlocale to de_DE, so here the hack:
from datetime import (datetime, timedelta)
import locale
print(locale.getlocale()) #gets none,none
locale.setlocale(locale.LC_ALL,'') #fix missing locale
print(locale.getlocale()) #here we go :D
l = 'Build Date : Mo 20 Jun 2016 02:46:10 CEST'
print(locale.getlocale())
dfields = l.strip().split()
dstr = ' '.join(dfields[3:7])
print(dstr)
bdate = datetime.strptime(dstr, '%a %d %b %Y')
print(bdate)
bdate += timedelta(days=1)
print(bdate)
date = bdate.strftime('%Y-%b-%d')
print(date)
Going to PR asap/EDIT : @suman we require having one locale.setlocale(locale.LC_ALL,'') to force python read real locale and have it in every part of Rockstor, where to put this two lines patch?
P.S.: german locale
[root@rockstone build]# ls a
ls: Zugriff auf a nicht möglich: Datei oder Verzeichnis nicht gefunden
As I’ve seen the locale is imported in the _strptime.py
"""
import time
**import locale**
import calendar
from re import compile as re_compile
from re import IGNORECASE
from re import escape as re_escape
from datetime import date as datetime_date
try:
from thread import allocate_lock as _thread_allocate_lock
except:
from dummy_thread import allocate_lock as _thread_allocate_lock
@Uwe_Ganswig and @Flyer this looks like a device on the system is returning an unexpected string for it’s size value!!
And we are not elegantly dealing with it.
@Uwe_Ganswig if your could paste the output of the following command executed on your Rockstor install into this forum thread it should help with working out what’s going wrong. If you could also proceed and follow the pasted output with a triple single inverted comma, each set on a line of it’s own, ie ``` it will format better within the post and aid in reading, such as I have done with the command in this post:
On en_US size get point separator, with de_DE comma separator. Because of that getlocale() python error your system is on de_DE, but python checks values/data thinking like en_US.
Same if you have locale to it_IT or fr_FR es_ES etc etc, but not your en_GB locale because US & GB have both decimal with point (looking to this nice wikipedia map I suppose probably related to Anglo-Saxon countries / not influeced by UK culture- not anglo-saxon countries…closing history channel eheh) Wikipedia decimal mark page
Hi all @Uwe_Ganswig, @sfranzen@phillxnet and @suman,
before being scolded by Guido van Rossum let’s amend my last sentence about locale bug in Python:
Thinking about possible versions related issues had a fresh new latest 2.7.12 python version (not on Rockstor machine)
Had same tests
Having same results finally said “Ok, better reading line by line Python locale docu” and…shame on me, that locale.getlocale() (same func is used over _strptime.py get_lang to handle localization)returning ('None', 'None') is well documented and desired behavior
@Uwe_Ganswig Thanks for the reply and for reporting the issue; this output confirms the findings of @Flyer re “,” rather than “.” in the “SIZE=“225,5G”” string interpretation as a result of locale setting and default Python function. It looks like @Flyer is on top of this one so I’ll back out.
No unfortunately not, but please see the following forum thread for future plans and a discussion on this:
@Flyer Thanks for the schooling, nicely demonstrated. I’m afraid I just dove in re your “…let’s call @phillxnet …” prompt without reading the thread carefully enough; nice find this one.
That’s what I was thinking about as well, but I don’t know whether there is one “right” way. Perhaps the cleanest way is to create the ultra short module
from locale import setlocale, LC_ALL
setlocale(LC_ALL, '')
and use this wherever we handle localised stuff? Django should already handle this appropriately, so the trouble is hopefully mostly within the Python utility modules (system folder).