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

Python3 fixes #99

Merged
merged 43 commits into from Sep 22, 2020
Merged

Python3 fixes #99

merged 43 commits into from Sep 22, 2020

Commits on Jan 3, 2020

  1. Update emonhub.service

    - Set the log dir mode with mkdir.
    - Use Type=exec, it's more resilient to some failures (i.e. absent binary).
    - Use a better name
    - Use the default dependencies which seemed to be duplicated here anyway. Remove nonexistent syslog.target
    - Remove PIDFile. It's unnecessary and systemd doesn't use it except for units of Type=forking
    - Use a slower RestartSec (the default of 100ms is probably inappropriate)
    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    a35f9ff View commit details
    Browse the repository at this point in the history
  2. Make logging lazy.

    Calls to logging functions should use %s/%d/etc and pass parameters
    instead of interpolating first. The logging module can avoid doing that
    work if the log message would be filtered anyway.
    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    51a3c18 View commit details
    Browse the repository at this point in the history
  3. More cleanups

    - Avoid import *
    - Use setdefault for dict initialisation.
    - Remove/simplify various bits.
    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    579a4a4 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    724e5ae View commit details
    Browse the repository at this point in the history
  5. Simplify EmonHubFileSetup.

    This class is only ever a ConfigObj wrapper, so remove the json code.
    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    45bfe44 View commit details
    Browse the repository at this point in the history
  6. Add log_backup_count and log_max_bytes settings.

    This adds config options to control the log file rotation.
    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    a360874 View commit details
    Browse the repository at this point in the history
  7. Typo.

    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    5269897 View commit details
    Browse the repository at this point in the history
  8. Revert removal of import *

    This import mechanism is fragile and needs to be converted into a true
    module. Revert this for now.
    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    ddbaa09 View commit details
    Browse the repository at this point in the history
  9. Fix log format types.

    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    ab0beaa View commit details
    Browse the repository at this point in the history
  10. Also catch SIGTERM.

    This means that emonhub shuts down cleanly when stopped by, e.g.,
    systemd.
    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    ada3181 View commit details
    Browse the repository at this point in the history
  11. Fix typo bug.

    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    4137587 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    ba2835d View commit details
    Browse the repository at this point in the history
  13. Tidy up imports.

    - Standard library imports should go first.
    - Remove unused or duplicate imports.
    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    9e3661b View commit details
    Browse the repository at this point in the history
  14. Fix missing super()

    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    9153ab2 View commit details
    Browse the repository at this point in the history
  15. Fix undefined variable bug.

    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    0e636c6 View commit details
    Browse the repository at this point in the history
  16. Tidy up logic.

    - expr == False -> not expr
    - expr == True -> expr (or expr is True, if the type isn't clear).
    - not x in y => x not in y
    - not x == "1" => x != "1"
    - omit range default
    - 'if not x or not y: pass else: z' => 'if x and y: z'
    - str.__len__ => len
    - x > 1 and x < 10 => 1 < x < 10
    - not x > y => x <= y
    - if x: if y: if z: _ => if x and y and x: _
    - BUGFIX: "a" and "b" in f => all(i in f for i in ["a","b"])
    - BUGFIX: .lower => .lower()
    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    dd8d1f7 View commit details
    Browse the repository at this point in the history
  17. Simplify code.

    - defaultdict to avoid initialising every entry up front
    - Use struct.calcsize instead of copying the values.
    - if x == 0: y = False: else y = True => y = bool(x)
    - list[len(list)-1] => list[-1]
    - math.pow(256, 1) => 0x08 etc.
    - x = bytearray(); x.append(y); x.append(z) => x = bytearray([y, z])
    - value = x; return value => return x
    bwduncan committed Jan 3, 2020
    1 Configuration menu
    Copy the full SHA
    e003356 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    41364ec View commit details
    Browse the repository at this point in the history
  19. Misc cleanups.

    - Create dicts at compile time.
    - Use startswith as it's less error prone.
    - Add some FIXMEs.
    - Make dict at compile time.
    - Use enumerate.
    - Lift sum out of if blocks.
    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    7d680f2 View commit details
    Browse the repository at this point in the history
  20. Use requests instead of urllib2.

    It's much easier to use and it didn't change from python2 to python3.
    
    I can't easily test PacketGen, though, but it seems to be unused.
    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    7f0253a View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    5fe771b View commit details
    Browse the repository at this point in the history
  22. Python3.

    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    03fb179 View commit details
    Browse the repository at this point in the history
  23. Encode strings for serial.

    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    f9359e0 View commit details
    Browse the repository at this point in the history
  24. Fix MQTT interfacer bug.

    We were passing a string where an integer port number was expected. Add
    a cast.
    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    844890f View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    87b1ecc View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    b441fd3 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    5171fdd View commit details
    Browse the repository at this point in the history
  28. Bump to v3.

    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    8199e31 View commit details
    Browse the repository at this point in the history
  29. Fix float divison error.

    This code shouldn't really be relying on division, but change it to
    return an integer anyway.
    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    d5dfb0f View commit details
    Browse the repository at this point in the history
  30. Use a beta version number.

    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    e4387ec View commit details
    Browse the repository at this point in the history
  31. Update emonhub.service

    - Set the log dir mode with mkdir.
    - Use Type=exec, it's more resilient to some failures (i.e. absent binary).
    - Use a better name
    - Use the default dependencies which seemed to be duplicated here anyway. Remove nonexistent syslog.target
    - Remove PIDFile. It's unnecessary and systemd doesn't use it except for units of Type=forking
    - Use a slower RestartSec (the default of 100ms is probably inappropriate)
    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    a164904 View commit details
    Browse the repository at this point in the history
  32. Make logging lazy.

    Calls to logging functions should use %s/%d/etc and pass parameters
    instead of interpolating first. The logging module can avoid doing that
    work if the log message would be filtered anyway.
    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    b0082b7 View commit details
    Browse the repository at this point in the history
  33. More cleanups

    - Avoid import *
    - Use setdefault for dict initialisation.
    - Remove/simplify various bits.
    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    9b5f5d7 View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    c717867 View commit details
    Browse the repository at this point in the history
  35. Simplify EmonHubFileSetup.

    This class is only ever a ConfigObj wrapper, so remove the json code.
    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    a594bf3 View commit details
    Browse the repository at this point in the history
  36. Add log_backup_count and log_max_bytes settings.

    This adds config options to control the log file rotation.
    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    4ba3b0f View commit details
    Browse the repository at this point in the history
  37. Typo.

    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    55401f2 View commit details
    Browse the repository at this point in the history
  38. Revert removal of import *

    This import mechanism is fragile and needs to be converted into a true
    module. Revert this for now.
    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    1192a11 View commit details
    Browse the repository at this point in the history
  39. Fix log format types.

    bwduncan committed Jan 3, 2020
    Configuration menu
    Copy the full SHA
    039e350 View commit details
    Browse the repository at this point in the history
  40. Configuration menu
    Copy the full SHA
    29ae56c View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    d1e67e9 View commit details
    Browse the repository at this point in the history

Commits on Aug 19, 2020

  1. Configuration menu
    Copy the full SHA
    07a5abd View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5311c50 View commit details
    Browse the repository at this point in the history