I’m deeply frustrated. First and foremost, I’ve been developing for three months for work purposes. Secure CRT is required to run scripts, and they’ve been working well so far. However, I need to consolidate all my functions into one Python file and have another file reference these functions, as is commonly done by developers.
I’ve tried several approaches, but nothing seems to work. I know it must be something simple, but I can’t find the mistake. It works fine in Visual Studio, but when I try to use the scripts in Secure CRT, I encounter two issues:
It doesn’t recognize the crt method (e.g. crt.dialog.message), even though it works perfectly in other Python files (without using custom imports). It doesn’t recognize the import module. I’ll provide the simplest code to help clarify what I’m trying to do.
----> BasicFunction.py File
# -*- coding: utf-8 -*-
def Hello():
print ("Hello, World!", end = "\n")
print ("This is silly")
# crt_screen = crt.screen
# crt_screen.Send("Hello, World!\r\n")
----> CallingFunction.py File
# $language = "python"
# $interface = "1.0"
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import BasicFunction
from BasicFunction import Hello
def main():
Hello()
main()
It is straightforward. Nothing special to understand the problem. However, in spite of this simple code, It doesn't work.
This is the result when I use the CallingFunction.py file on secure CRT
Syntax Error
Error: invalid syntaxFile:
C:/ ...
Line 9
import BasicFunction
Please, does anybody can help me? I need to reuse these functions again and again :(
Import all functions from a file to use them from another different python file.