0

I am facing issue when I import a Python file that uses ctypes.cdll.LoadLibrary function. When I try that, os.system('cls') doesn't clear the screen as it should. When I remove the line with ctypes.cdll.LoadLibrary, os.system('cls') works properly. The .DLL file contains a GoLang TLS solution. Code snippets below.

Here's an example file where os.system('cls') doesn't clear the screen.

import os
import tls

session = tls.create_client()

print('Session created.')

os.system('cls')

print('Screen cleared.')

__init__.py in tls dir:

# ------------------------------------------------------------------------------- #

if getattr(sys, 'frozen', False):
    file_dir = f'{sys._MEIPASS}/tls/titanium_tls'
else:
    file_dir = os.path.dirname(os.path.abspath(__file__))

tls = ctypes.cdll.LoadLibrary(f'{file_dir}/titanum_test.{platform.system().lower()}' if str(platform.system()) != 'Windows' else f'{file_dir}/titanum_test.dll')

tls.Request.restype = ctypes.c_char_p
tls.Request.argtypes = [ctypes.c_char_p]

# ------------------------------------------------------------------------------- #

Output of example script:

Session created.
Screen cleared.

Process finished with exit code 0

Output when tls = ctypes.cdll.LoadLibrary(f'{file_dir}/titanum_test.{platform.system().lower()}' if str(platform.system()) != 'Windows' else f'{file_dir}/titanum_test.dll') line is removed:

Session created.
 Screen cleared.

Process finished with exit code 0

The space is the place where os.system('cls') is clearing the screen and it works properly when the line that I mentioned above is removed.

Of course i cannot use my __init__.py file when this line is removed.

Sorry if there are any issues inside my questions.

Output returned by print(os.system('cls')) Is: 1

1 Answers1

0

I found solution. The soulution is:

import subprocess

subprocess.run('cls', shell=True)