diff options
author | Ville Skyttä <ville.skytta@iki.fi> | 2017-09-15 20:42:01 +0300 |
---|---|---|
committer | Ville Skyttä <ville.skytta@iki.fi> | 2017-09-17 08:26:55 +0300 |
commit | 989816d3a6b8cab160608543f36b9f76528eb2fa (patch) | |
tree | 25336b4ac4f0c8324db0e479a6adf19c4ea257d9 /examples/uptime.py | |
parent | 11445503eab6ac8356f25a6d5dbfa7208abddab7 (diff) | |
download | pexpect-git-989816d3a6b8cab160608543f36b9f76528eb2fa.tar.gz |
Python 3.6 invalid escape sequence deprecation fixes
https://docs.python.org/3/whatsnew/3.6.html#deprecated-python-behavior
Diffstat (limited to 'examples/uptime.py')
-rwxr-xr-x | examples/uptime.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/uptime.py b/examples/uptime.py index 659edfc..86b8dff 100755 --- a/examples/uptime.py +++ b/examples/uptime.py @@ -54,7 +54,7 @@ import re p = pexpect.spawnu('uptime') # This parses uptime output into the major groups using regex group matching. -p.expect('up\s+(.*?),\s+([0-9]+) users?,\s+load averages?: ([0-9]+\.[0-9][0-9]),?\s+([0-9]+\.[0-9][0-9]),?\s+([0-9]+\.[0-9][0-9])') +p.expect(r'up\s+(.*?),\s+([0-9]+) users?,\s+load averages?: ([0-9]+\.[0-9][0-9]),?\s+([0-9]+\.[0-9][0-9]),?\s+([0-9]+\.[0-9][0-9])') duration, users, av1, av5, av15 = p.match.groups() # The duration is a little harder to parse because of all the different @@ -65,14 +65,14 @@ days = '0' hours = '0' mins = '0' if 'day' in duration: - p.match = re.search('([0-9]+)\s+day',duration) + p.match = re.search(r'([0-9]+)\s+day',duration) days = str(int(p.match.group(1))) if ':' in duration: p.match = re.search('([0-9]+):([0-9]+)',duration) hours = str(int(p.match.group(1))) mins = str(int(p.match.group(2))) if 'min' in duration: - p.match = re.search('([0-9]+)\s+min',duration) + p.match = re.search(r'([0-9]+)\s+min',duration) mins = str(int(p.match.group(1))) # Print the parsed fields in CSV format. |