Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapping commands into py2exe package #15

Open
curunoir opened this issue Jul 29, 2022 · 1 comment
Open

Wrapping commands into py2exe package #15

curunoir opened this issue Jul 29, 2022 · 1 comment

Comments

@curunoir
Copy link

curunoir commented Jul 29, 2022

Hello guys,

first thanks for the work !

I have the need to embed this package and particularly the snmp-record-command into a portable Windows executable so I have digged into py2exe and did some tests. I also noticed in the setup.py file some references of py2exe so I guess that what I want is doable.

I have managed to do some things with this py2exe setup.py:

from distutils.core import setup
import py2exe

setup(console=['snmp-record-command.py'])

and in snmp-record-command.py

import subprocess
import sys

sys.argv.pop(0)
return_code = subprocess.call(['snmpsim-record-commands'] + sys.argv)
print("Output of snmpsim-record-commands call() : ", return_code)

And this is working if I'm using the executable done

snmp-record-command.exe --agent-udpv4-endpoint=24.x.x.x --...

But my approach is not good because the subprocess.call(['snmpsim-record-commands'] + sys.argv) needs to have python + snmpsim already installed in the system which is not what I really wand because I need the executable to be standalone.

The problem is I don't understand how I could make. Can someone here points me to the good direction ?
Thanks

@curunoir
Copy link
Author

curunoir commented Aug 2, 2022

After some work i have found that this approach is getting better results but still don't work

setup(
    console=['snmpsim/commands/cmd2rec.py'],
    packages= setuptools.find_packages(),
    include_package_data=True,
    )

Which gaves me this output
process terminated: No module __SNMP-FRAMEWORK-MIB loaded at <pysnmp.smi.builder.MibBuilder object at 0x00000173C47D68E0>Traceback (most
recent call last):; File "cmd2rec.py", line 740, in ; File "cmd2rec.py", line 361, in main; File "pysnmp\entity\engine.pyc", line 90, in init; File "pysnmp\smi\builder.pyc", line 443, in importSymbols;pysnmp.smi.error.MibNotFoundError: No module __SNMP-FRAMEWORK-MIB loaded at <pysnmp.smi.builder.MibBuilder object at 0x00000173C47D68E0>;
PS C:\Users\curun\source\repos\snmpsim-master\dist> .\cmd2rec.exe --agent-udpv4-en

The lacking No module __SNMP-FRAMEWORK-MIB looks like to be a folder from pysnmp which is not included into the library.zip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant