Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import_logs.py: ValueError: invalid literal for int() with base 10: '-' #4267

Closed
anonymous-matomo-user opened this issue Nov 2, 2013 · 1 comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.

Comments

@anonymous-matomo-user
Copy link

Importing our apache logs I get the following error:

Traceback (most recent call last):
  File "/var/alternc/html/a/analytics/piwik/misc/log-analytics/import_logs.py", line 1663, in <module>
    main()
  File "/var/alternc/html/a/analytics/piwik/misc/log-analytics/import_logs.py", line 1627, in main
    parser.parse(filename)
  File "/var/alternc/html/a/analytics/piwik/misc/log-analytics/import_logs.py", line 1536, in parse
    hit.length = int(str(format.get('length')))
ValueError: invalid literal for int() with base 10: '-'

Here is an easy fix:

diff --git a/misc/log-analytics/import_logs.py b/misc/log-analytics/import_logs.py
index 56f28c1..dcbc770 100755
--- a/misc/log-analytics/import_logs.py
+++ b/misc/log-analytics/import_logs.py
@@ -1534,7 +1534,7 @@ class Parser(object):
             hit.ip = format.get('ip')
             try:
                 hit.length = int(format.get('length'))
-            except BaseFormatException:
+            except:
                 # Some lines or formats don't have a length (e.g. 304 redirects, IIS logs)
                 hit.length = 0

Thanks

@mattab
Copy link
Member

mattab commented Nov 2, 2013

Fixed in master, thanks for the report!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

2 participants