File: deb_use_system_serial

package info (click to toggle)
psychopy 2020.2.10%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 44,056 kB
  • sloc: python: 119,649; javascript: 3,022; makefile: 148; sh: 125; xml: 9
file content (42 lines) | stat: -rw-r--r-- 1,407 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From: Yaroslav Halchenko <debian@onerussian.com>
Subject: Importer for systemwide serial module

---
 psychopy/serial.py |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
 create mode 100644 psychopy/serial.py

--- /dev/null
+++ b/psychopy/serial.py
@@ -0,0 +1,31 @@
+#emacs: -*- mode: python-mode; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
+#ex: set sts=4 ts=4 sw=4 et:
+"""
+ Little helper script to minimize intrusion into upstream code relying
+ on psychopy.serial availability.
+
+ Copyright (C) 2009, Yaroslav Halchenko
+
+ Distributed under the license terms of python-psychopy package.
+"""
+import sys
+
+if sys.version_info[:2] >= (2, 5):
+    # enforce absolute import
+    serial = __import__('serial', globals(), locals(),
+                        ['Serial', 'PARITY_EVEN', 'STOPBITS_TWO'], 0)
+    # hackish way to bind needed names, not sure why
+    # fromlist argument wasn't in effect
+    locals().update(serial.__dict__)
+    #Serial = serial.Serial
+    #PARITY_EVEN = serial.PARITY_EVEN
+    #STOPBITS_TWO = serial.STOPBITS_TWO
+else:
+    # little trick to be able to import 'serial' package (which has same
+    # name)
+    oldname = __name__
+    # crazy name with close to zero possibility to cause whatever
+    __name__ = 'iaugf9zrkjsbdv99'
+    from serial import *
+    # restore old settings
+    __name__ = oldname