File tree Expand file tree Collapse file tree 2 files changed +6
-12
lines changed Expand file tree Collapse file tree 2 files changed +6
-12
lines changed Original file line number Diff line number Diff line change 1
- # pylint: disable=import-outside-toplevel
2
-
3
1
import bpy
2
+ import serial
3
+ import websocket
4
4
5
5
from bpy .types import Operator
6
6
from ..utils .live_mode import LiveMode
@@ -65,8 +65,6 @@ def execute(self, context):
65
65
return {'CANCELLED' }
66
66
67
67
def open_serial (self , _context ):
68
- import serial
69
-
70
68
try :
71
69
serial_connection = serial .Serial (self .serial_port , self .serial_baud )
72
70
except (serial .SerialException , ValueError ):
@@ -91,8 +89,6 @@ def open_serial(self, _context):
91
89
return {'FINISHED' }
92
90
93
91
def open_socket (self , _context ):
94
- import websocket
95
-
96
92
socket_url = f"ws://{ self .socket_host } :{ self .socket_port } { self .socket_path } "
97
93
socket_connection = websocket .WebSocket ()
98
94
socket_connection .settimeout (1 )
Original file line number Diff line number Diff line change 1
- # pylint: disable=import-outside-toplevel, broad-exception-caught
1
+ # pylint: disable=broad-exception-caught
2
2
3
3
import time
4
4
import math
5
5
import bpy
6
+ import serial
7
+ import websocket
6
8
7
9
from ..utils .servo_settings import get_active_pose_bones
8
10
from ..utils .converter import calculate_position
11
+ from serial .tools import list_ports
9
12
10
13
class LiveMode :
11
14
COMMAND_START = 0x3C
@@ -26,9 +29,6 @@ def set_connection(cls, connection):
26
29
27
30
@classmethod
28
31
def is_connected (cls ):
29
- import serial
30
- import websocket
31
-
32
32
method = bpy .context .window_manager .servo_animation .live_mode_method
33
33
34
34
if method == LiveMode .METHOD_SERIAL :
@@ -63,8 +63,6 @@ def disable_handler(cls):
63
63
64
64
@classmethod
65
65
def get_serial_ports (cls ):
66
- from serial .tools import list_ports
67
-
68
66
ports = []
69
67
70
68
for port in list_ports .comports ():
You can’t perform that action at this time.
0 commit comments