How to Hide the wc3270 emulator processsing

100 views
Skip to first unread message

Aravind Raghavan

unread,
May 27, 2019, 7:52:05 PM5/27/19
to BlazeLibs
Hi Team,

I have been using Python py3270 to connect with wc3270 emulator. Is there a way to hide the emulator process. 

Thanks,
Aravind

Randy Syring

unread,
May 27, 2019, 9:21:00 PM5/27/19
to blaz...@googlegroups.com
Maybe use the s3270 binary or whatever the windows equivalent is.

Randy Syring
Husband | Father | Redeemed Sinner

"For what does it profit a man to gain the whole world and forfeit his soul?" (Mark 8:36 ESV)

--
You received this message because you are subscribed to the Google Groups "BlazeLibs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blazelibs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blazelibs/2ccfe605-7041-4463-8fef-539abfe9268e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Isaac

unread,
May 28, 2019, 9:30:26 AM5/28/19
to BlazeLibs
I can do something like this and it seems to hide the process: 

host = "yourmf"
e = ModEmulator(visible=False)
e.connect(host)

Aravind Raghavan

unread,
May 28, 2019, 10:23:36 AM5/28/19
to BlazeLibs
Hi Issac,

which import library do you for ModEmulator. I am getting below error.

Traceback (most recent call last):
  File "C:/Users/aragk/Documents/Personal/Work/Interlink/Pre Assembly/PythonScrapper V14.py", line 15, in <module>
    from py3270 import ModEmulator
ImportError: cannot import name 'ModEmulator'

Thanks,
Aravind

Isaac

unread,
May 28, 2019, 10:30:57 AM5/28/19
to BlazeLibs
Oh sorry, I just copied and pasted and didn't check it.
I'm using this: 
from py3270 import Emulator

But I have a custom class inheriting from Emulator called ModEmulator.
So instead of my first post try this (just rename ModEmulator to Emulator):
host = "yourhost"
e = Emulator(visible=True)
e.connect(host)

Aravind Raghavan

unread,
May 28, 2019, 11:10:41 AM5/28/19
to BlazeLibs
Hi Issac,

This one works fine but I am trying to find a way to hide the emulator processing. It doesn't work if I make the visible condition to false. 

it will be helpful if  you can share the 'custom class inheriting from Emulator called ModEmulator'. 

from py3270 import Emulator
# em = Emulator(visible=False)

Error:
Traceback (most recent call last):
  File "<input>", line 14, in <module>
  File "C:\Users\aragk\PycharmProjects\PreAssembly Automation\venv\lib\site-packages\py3270\__init__.py", line 358, in connect
    self.exec_command(command)
  File "C:\Users\aragk\PycharmProjects\PreAssembly Automation\venv\lib\site-packages\py3270\__init__.py", line 308, in exec_command
    c.execute()
  File "C:\Users\aragk\PycharmProjects\PreAssembly Automation\venv\lib\site-packages\py3270\__init__.py", line 82, in execute
    return self.handle_result(result.decode("ascii"))
  File "C:\Users\aragk\PycharmProjects\PreAssembly Automation\venv\lib\site-packages\py3270\__init__.py", line 102, in handle_result
    raise CommandError(msg.decode("ascii"))
py3270.CommandError: SSL: InitializeSecurityContext: error 0x80090322 (The target principal name is incorrect.)

Thanks,
Aravind

Isaac

unread,
May 28, 2019, 12:23:12 PM5/28/19
to BlazeLibs
Maybe I misunderstood what you are trying to do. What I posted will just hide the wc3270 window from showing when you run your script.
Can you explain more on what you are trying to do?

Isaac

unread,
May 28, 2019, 12:32:02 PM5/28/19
to BlazeLibs
Oh also, it looks like it runs a different executable on Windows when you set "Emulator(visible=False)". The exe that runs is "ws3270.exe" which I think is the headless version of "wc3270.exe". Maybe "ws3270.exe" isn't in your PATH or in the same location as your "wc3270.exe"?

Aravind Raghavan

unread,
May 28, 2019, 2:05:10 PM5/28/19
to BlazeLibs
Hi Issac,

Thanks for the suggestion. I set the Emulator (visible=False) and it runs the ws3270.exe but there is a blank exe window getting opened.  Is there a way to hide that one as well ?

Thanks,
Aravind

Isaac

unread,
May 31, 2019, 9:15:52 AM5/31/19
to BlazeLibs
I do not know, sorry. When I set that I don't get any windows.

Aravind Raghavan

unread,
May 31, 2019, 9:23:05 AM5/31/19
to BlazeLibs
Hi Issac,

It is working fine...The blank exe window appears but I guess that is used for displaying print statements..

thanks,
Aravind

Randy Syring

unread,
Jun 3, 2019, 10:13:55 AM6/3/19
to blaz...@googlegroups.com, Aravind Raghavan
The problem you are having is more of a Windows issue than a py3270 issue.  It's just the way they handle windows.  This may help:

https://superuser.com/questions/62525/run-a-batch-file-in-a-completely-hidden-way


Randy Syring
Husband | Father | Redeemed Sinner

"For what does it profit a man to gain the whole world
and forfeit his soul?" (Mark 8:36 ESV)


STaRNiGHT

unread,
Jun 26, 2019, 9:23:31 AM6/26/19
to BlazeLibs
Hi,

I use

em = Emulator(visible=False, timeout=30, app=None, args=["-model", "3279-2", "-charset", "spanish-euro"])

This forces py3270 to use the executable ws3270 which has no echo on the screen.

Unfortunately, if the python program does not have console view Windows generates a unnecessary black screen, 
if it's a problem, you can hide using win32com



def enum_callback(hwnd, results):
 winlist
.append((hwnd, win32gui.GetWindowText(hwnd)))

toplist
= []
winlist
= []
win32gui
.EnumWindows(enum_callback, toplist)
winws3270
= [(hwnd) for hwnd, title in winlist if 'ws3270' in title.lower()]
if len(winws3270) > 0: win32gui.ShowWindow(winws3270[0], win32con.SW_HIDE)

The solution is not very elegant and I am always thinking about improving it but it works fine.

Regards

Josse

Reply all
Reply to author
Forward
0 new messages