Browse Source

[lint] clean errors

Maxime Alves LIRMM@home 4 years ago
parent
commit
13cd4273b9

+ 6
- 3
pyheatpump/cli.py View File

25
 @click.option('--version', is_flag=True)
25
 @click.option('--version', is_flag=True)
26
 @click.pass_context
26
 @click.pass_context
27
 def cli(ctx, version):
27
 def cli(ctx, version):
28
+    """
28
     if version:
29
     if version:
29
         from pyheatpump import version
30
         from pyheatpump import version
30
         return click.echo(pyheatpump.version())
31
         return click.echo(pyheatpump.version())
32
+    """
33
+    pass
31
 
34
 
32
 
35
 
33
 @click.option('--host', default=None)
36
 @click.option('--host', default=None)
174
         last_update = get_last_update()
177
         last_update = get_last_update()
175
     
178
     
176
     post_packets = [
179
     post_packets = [
177
-        Heatpump(mac_address, last_update, ['Analog']).__dict__(),
178
-        Heatpump(mac_address, last_update, ['Digital']).__dict__(),
179
-        Heatpump(mac_address, last_update, ['Integer']).__dict__()
180
+        Heatpump(mac_address, last_update, ['Analog']).packet,
181
+        Heatpump(mac_address, last_update, ['Digital']).packet,
182
+        Heatpump(mac_address, last_update, ['Integer']).packet
180
     ]
183
     ]
181
 
184
 
182
     base_url = {
185
     base_url = {

+ 2
- 0
pyheatpump/config.py View File

1
 #!/usr/bin/env python3
1
 #!/usr/bin/env python3
2
 import os
2
 import os
3
 import re
3
 import re
4
+import sys
4
 from datetime import datetime
5
 from datetime import datetime
5
 from configparser import ConfigParser
6
 from configparser import ConfigParser
6
 from starlette.requests import Request
7
 from starlette.requests import Request
7
 from starlette.routing import Route, Router
8
 from starlette.routing import Route, Router
8
 from starlette.responses import PlainTextResponse, JSONResponse
9
 from starlette.responses import PlainTextResponse, JSONResponse
10
+from starlette.exceptions import HTTPException
9
 from pprint import pprint
11
 from pprint import pprint
10
 import uvicorn
12
 import uvicorn
11
 import json
13
 import json

+ 3
- 3
pyheatpump/db.py View File

34
         return True
34
         return True
35
 
35
 
36
 
36
 
37
-    def commit():
37
+    def commit(self):
38
         """
38
         """
39
             Default mode of connecting is autocommit
39
             Default mode of connecting is autocommit
40
         """
40
         """
78
                 print(e)
78
                 print(e)
79
                 return []
79
                 return []
80
             except sqlite3.OperationalError as e:
80
             except sqlite3.OperationalError as e:
81
-                raise Exception('Can\'t find DB file %s'.format(filename)) from e
81
+                raise Exception(f'Can\'t find DB file {filename}') from e
82
 
82
 
83
 
83
 
84
 
84
 
93
         if type(attr) == str:
93
         if type(attr) == str:
94
             q = ("SELECT * FROM {tablename} WHERE ? LIKE '?'", (key, attr))
94
             q = ("SELECT * FROM {tablename} WHERE ? LIKE '?'", (key, attr))
95
         elif type(attr) == int:
95
         elif type(attr) == int:
96
-            q = ("SELECT * FROM {tablename} WHERE ? LIKE ?", (key, attr))
96
+            q = ("SELECT * FROM {tablename} WHERE ? = ?", (key, attr))
97
 
97
 
98
         res = []
98
         res = []
99
         for row in DB.sql(*q):
99
         for row in DB.sql(*q):

+ 11
- 2
pyheatpump/models/heatpump.py View File

27
             self.var_types = VariableType.getall()
27
             self.var_types = VariableType.getall()
28
 
28
 
29
     def __str__(self):
29
     def __str__(self):
30
-        return str(self.__dict__())
30
+        res = f'{self.mac_address} ['
31
+        res += ', '.join([
32
+            var_type.slabel
33
+            for var_type in self.var_types
34
+        ])
35
+        res += ']'
31
 
36
 
32
-    def __dict__(self):
37
+    @property
38
+    def packet(self):
39
+        """
40
+        Returns an object containing all values and the current macAddress
41
+        """
33
         r = {'macAddress': self.macformat}
42
         r = {'macAddress': self.macformat}
34
         if not self.last_update:
43
         if not self.last_update:
35
             # Since beginning
44
             # Since beginning

+ 4
- 4
pyheatpump/models/variable_type.py View File

2
 
2
 
3
 
3
 
4
 class VariableType(RowClass):
4
 class VariableType(RowClass):
5
-    slabel: str = None
6
-    label: str = None
7
-    type: str = None
5
+    slabel: str = '' 
6
+    label: str = '' 
7
+    type: str = '' 
8
     start_address: int = None
8
     start_address: int = None
9
     end_address: int = None
9
     end_address: int = None
10
 
10
 
28
             return bool
28
             return bool
29
 
29
 
30
 
30
 
31
-    def select():
31
+    def select(self):
32
         try:
32
         try:
33
             elt = next(super().select('slabel', 'var_type'))
33
             elt = next(super().select('slabel', 'var_type'))
34
         except StopIteration:
34
         except StopIteration:

Loading…
Cancel
Save