smartpi 0.1.29__py3-none-any.whl → 0.1.30__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
smartpi/__init__.py CHANGED
@@ -2,5 +2,5 @@ from ._gui import gui
2
2
 
3
3
  __all__ = ["base_driver","gui","ultrasonic","touch_sensor","temperature","humidity","light_sensor","color_sensor","motor","servo","led","flash"]
4
4
 
5
- __version__ = "0.1.29"
5
+ __version__ = "0.1.30"
6
6
 
smartpi/_gui.py CHANGED
@@ -1,15 +1,32 @@
1
+
2
+
1
3
  import socket
2
4
  import json
3
5
  import time
4
6
 
5
7
  class gui_client:
6
- def __init__(self, host="127.0.0.1", port=65167):
7
- self.sock = socket.create_connection((host, port))
8
- self.clear()
8
+ def __init__(self, host="127.0.0.1", port=65167, timeout=2.0):
9
+ self.sock = None
10
+ try:
11
+ self.sock = socket.create_connection((host, port), timeout=timeout)
12
+ self.clear()
13
+ except :
14
+ self.sock = None
9
15
 
16
+ def is_connected(self):
17
+ result = False
18
+ if self.sock is not None:
19
+ result = True
20
+ return result
21
+
10
22
  def _send(self, cmd):
11
- self.sock.sendall((json.dumps(cmd) + "\n").encode())
12
- time.sleep(0.1)
23
+ if self.sock is None:
24
+ return
25
+ try:
26
+ self.sock.sendall((json.dumps(cmd) + "\n").encode())
27
+ time.sleep(0.1)
28
+ except :
29
+ self.sock = None
13
30
 
14
31
  def show_text(self, x, y, text, color="black", size=16):
15
32
  self._send({"type": "text", "x": x, "y": y, "text": text, "color": color, "size": size})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smartpi
3
- Version: 0.1.29
3
+ Version: 0.1.30
4
4
  Summary: A library use for H2-RCU
5
5
  Author: ZMROBO
6
6
  Classifier: Programming Language :: Python :: 3
@@ -1,5 +1,5 @@
1
- smartpi/__init__.py,sha256=DD3m7tPhima564oB5wb8kPTu1puPptby_1t8IlPB5d0,199
2
- smartpi/_gui.py,sha256=QObbzAx3m9m7E6A0uQ0Ek_Ofb3stSl7ef96FdVpMVn4,1779
1
+ smartpi/__init__.py,sha256=KxiHhAK2d08nDxhs_Me1ZQHnYHBUfjBfIwCDNy0nF3s,199
2
+ smartpi/_gui.py,sha256=ij-6HZAEIwdy_hvU7f0NkyQjx_-eephijlKbGUhf8Uo,2177
3
3
  smartpi/base_driver.py,sha256=hJ5_Rph1BT-riYiW1pgw685WAgEMjpqDF264BLSP6hk,24392
4
4
  smartpi/color_sensor.py,sha256=YXJjknYjp7teTZsHYZRAWgi73CH0MhBp1go9y0Inxyo,498
5
5
  smartpi/cw2015.py,sha256=1lAF-pi_ye_ya1AZQS1sjbgsDf7MThO5IAskKsNGBzA,5695
@@ -14,7 +14,7 @@ smartpi/temperature.py,sha256=VT79CYA41q1d_4AM-Y0eIMeIw7AtCkSXjWVws6Yx5yE,462
14
14
  smartpi/touch_sensor.py,sha256=P57RRQlqY0KexpMi-ydqwF5albOKCBOGb0Rb6zeVTqk,440
15
15
  smartpi/trace.py,sha256=tut7BMbq87ShaR5eNuv7PZtAEz9DS5_BDf0_muIZ-tQ,4577
16
16
  smartpi/ultrasonic.py,sha256=kmVpUfvE1oHoqgv92ZU6Fi-sO6DSwm10ssKsImNeOkY,624
17
- smartpi-0.1.29.dist-info/METADATA,sha256=EX2b2m3MfzrJHoX2hRGSQJhlBYMWpFuRcwPttrctwhA,311
18
- smartpi-0.1.29.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
19
- smartpi-0.1.29.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
20
- smartpi-0.1.29.dist-info/RECORD,,
17
+ smartpi-0.1.30.dist-info/METADATA,sha256=HdapesvaqrPYL7dI86CO7s1gZ01ws0MbCfVdOIqByF8,311
18
+ smartpi-0.1.30.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
19
+ smartpi-0.1.30.dist-info/top_level.txt,sha256=PoLhUCmWAiQUg5UeN2fS-Y1iQyBbF2rdUlizXtpHGRQ,8
20
+ smartpi-0.1.30.dist-info/RECORD,,