adoroszlai commented on a change in pull request #5: AMBARI-24763. Infra Solr 
upgrade (2.7.x): ValueError: invalid literal for float():
URL: https://github.com/apache/ambari-infra/pull/5#discussion_r224575118
 
 

 ##########
 File path: ambari-infra-solr-client/src/main/python/migrationHelper.py
 ##########
 @@ -946,9 +946,10 @@ def human_size(size_bytes):
   return "%s %s" % (formatted_size, suffix)
 
 def parse_size(human_size):
+  import locale
   units = {"bytes": 1, "KB": 1024, "MB": 1024**2, "GB": 1024**3, "TB": 1024**4 
}
   number, unit = [string.strip() for string in human_size.split()]
-  return int(float(number)*units[unit])
+  return int(locale.atof(number)*units[unit])
 
 Review comment:
   I'm not sure `locale.atof` fixes the problem.
   
   ```
   >>> locale.atof("1,013.88")
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/usr/lib64/python2.7/locale.py", line 316, in atof
       return func(string)
   ValueError: invalid literal for float(): 1,013.88
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to