Skip to content

Commit

Permalink
fix ctypes not defined
Browse files Browse the repository at this point in the history
This update fix ctypes is not defined in linux
  • Loading branch information
damp11113 committed Jan 4, 2025
1 parent 78a6459 commit 64bb2b0
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 9 deletions.
59 changes: 57 additions & 2 deletions demo/demo1.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import os
os.environ["damp11113_load_all_module"] = "NO"

from damp11113.utils import TextFormatter
from damp11113.file import sort_files, allfiles
import socket
import time
import cv2
Expand All @@ -28,6 +26,63 @@
from PyserSSH.system.RemoteStatus import remotestatus
from PyserSSH.utils.ServerManager import ServerManager

class TextFormatter:
RESET = "\033[0m"
TEXT_COLORS = {
"black": "\033[30m",
"red": "\033[31m",
"green": "\033[32m",
"yellow": "\033[33m",
"blue": "\033[34m",
"magenta": "\033[35m",
"cyan": "\033[36m",
"white": "\033[37m"
}
TEXT_COLOR_LEVELS = {
"light": "\033[1;{}m", # Light color prefix
"dark": "\033[2;{}m" # Dark color prefix
}
BACKGROUND_COLORS = {
"black": "\033[40m",
"red": "\033[41m",
"green": "\033[42m",
"yellow": "\033[43m",
"blue": "\033[44m",
"magenta": "\033[45m",
"cyan": "\033[46m",
"white": "\033[47m"
}
TEXT_ATTRIBUTES = {
"bold": "\033[1m",
"italic": "\033[3m",
"underline": "\033[4m",
"blink": "\033[5m",
"reverse": "\033[7m",
"strikethrough": "\033[9m"
}

@staticmethod
def format_text_truecolor(text, color=None, background=None, attributes=None, target_text=''):
formatted_text = ""
start_index = text.find(target_text)
end_index = start_index + len(target_text) if start_index != -1 else len(text)

if color:
formatted_text += f"\033[38;2;{color}m"

if background:
formatted_text += f"\033[48;2;{background}m"

if attributes in TextFormatter.TEXT_ATTRIBUTES:
formatted_text += TextFormatter.TEXT_ATTRIBUTES[attributes]

if target_text == "":
formatted_text += text + TextFormatter.RESET
else:
formatted_text += text[:start_index] + text[start_index:end_index] + TextFormatter.RESET + text[end_index:]

return formatted_text

useraccount = AccountManager(allow_guest=True, autoload=True, autosave=True)

if not os.path.isfile("autosave_session.ses"):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='PyserSSH',
version='5.1',
version='5.1.1',
license='MIT',
author='DPSoftware Foundation',
author_email='contact@damp11113.xyz',
Expand Down
2 changes: 1 addition & 1 deletion src/PyserSSH/system/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
SOFTWARE.
"""

version = "5.1"
version = "5.1.1"

system_banner = (
f"\033[36mPyserSSH V{version} \033[0m"
Expand Down
11 changes: 6 additions & 5 deletions src/PyserSSH/system/remotestatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@

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

class LASTINPUTINFO(ctypes.Structure):
_fields_ = [
('cbSize', ctypes.c_uint),
('dwTime', ctypes.c_uint),
]
if platform.system() == "Windows":
class LASTINPUTINFO(ctypes.Structure):
_fields_ = [
('cbSize', ctypes.c_uint),
('dwTime', ctypes.c_uint),
]

def get_idle_time():
if platform.system() == "Windows":
Expand Down
1 change: 1 addition & 0 deletions upload.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ python setup.py sdist
title uploading to pypi
twine upload -r pypi dist/*

title done!
pause

0 comments on commit 64bb2b0

Please sign in to comment.