Skip to content

Commit 64bb2b0

Browse files
committed
fix ctypes not defined
This update fix ctypes is not defined in linux
1 parent 78a6459 commit 64bb2b0

File tree

5 files changed

+66
-9
lines changed

5 files changed

+66
-9
lines changed

demo/demo1.py

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import os
22
os.environ["damp11113_load_all_module"] = "NO"
33

4-
from damp11113.utils import TextFormatter
5-
from damp11113.file import sort_files, allfiles
64
import socket
75
import time
86
import cv2
@@ -28,6 +26,63 @@
2826
from PyserSSH.system.RemoteStatus import remotestatus
2927
from PyserSSH.utils.ServerManager import ServerManager
3028

29+
class TextFormatter:
30+
RESET = "\033[0m"
31+
TEXT_COLORS = {
32+
"black": "\033[30m",
33+
"red": "\033[31m",
34+
"green": "\033[32m",
35+
"yellow": "\033[33m",
36+
"blue": "\033[34m",
37+
"magenta": "\033[35m",
38+
"cyan": "\033[36m",
39+
"white": "\033[37m"
40+
}
41+
TEXT_COLOR_LEVELS = {
42+
"light": "\033[1;{}m", # Light color prefix
43+
"dark": "\033[2;{}m" # Dark color prefix
44+
}
45+
BACKGROUND_COLORS = {
46+
"black": "\033[40m",
47+
"red": "\033[41m",
48+
"green": "\033[42m",
49+
"yellow": "\033[43m",
50+
"blue": "\033[44m",
51+
"magenta": "\033[45m",
52+
"cyan": "\033[46m",
53+
"white": "\033[47m"
54+
}
55+
TEXT_ATTRIBUTES = {
56+
"bold": "\033[1m",
57+
"italic": "\033[3m",
58+
"underline": "\033[4m",
59+
"blink": "\033[5m",
60+
"reverse": "\033[7m",
61+
"strikethrough": "\033[9m"
62+
}
63+
64+
@staticmethod
65+
def format_text_truecolor(text, color=None, background=None, attributes=None, target_text=''):
66+
formatted_text = ""
67+
start_index = text.find(target_text)
68+
end_index = start_index + len(target_text) if start_index != -1 else len(text)
69+
70+
if color:
71+
formatted_text += f"\033[38;2;{color}m"
72+
73+
if background:
74+
formatted_text += f"\033[48;2;{background}m"
75+
76+
if attributes in TextFormatter.TEXT_ATTRIBUTES:
77+
formatted_text += TextFormatter.TEXT_ATTRIBUTES[attributes]
78+
79+
if target_text == "":
80+
formatted_text += text + TextFormatter.RESET
81+
else:
82+
formatted_text += text[:start_index] + text[start_index:end_index] + TextFormatter.RESET + text[end_index:]
83+
84+
return formatted_text
85+
3186
useraccount = AccountManager(allow_guest=True, autoload=True, autosave=True)
3287

3388
if not os.path.isfile("autosave_session.ses"):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='PyserSSH',
5-
version='5.1',
5+
version='5.1.1',
66
license='MIT',
77
author='DPSoftware Foundation',
88
author_email='[email protected]',

src/PyserSSH/system/info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
SOFTWARE.
2626
"""
2727

28-
version = "5.1"
28+
version = "5.1.1"
2929

3030
system_banner = (
3131
f"\033[36mPyserSSH V{version} \033[0m"

src/PyserSSH/system/remotestatus.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@
4242

4343
logger = logging.getLogger("PyserSSH.RemoteStatus")
4444

45-
class LASTINPUTINFO(ctypes.Structure):
46-
_fields_ = [
47-
('cbSize', ctypes.c_uint),
48-
('dwTime', ctypes.c_uint),
49-
]
45+
if platform.system() == "Windows":
46+
class LASTINPUTINFO(ctypes.Structure):
47+
_fields_ = [
48+
('cbSize', ctypes.c_uint),
49+
('dwTime', ctypes.c_uint),
50+
]
5051

5152
def get_idle_time():
5253
if platform.system() == "Windows":

upload.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ python setup.py sdist
99
title uploading to pypi
1010
twine upload -r pypi dist/*
1111

12+
title done!
1213
pause

0 commit comments

Comments
 (0)