0

The task is to open an application called t32 from the command line in a linuix machine using python script and 2 arguments is what I understand. but i am facing the following error:

sh-5.0$ python2 t32start.py --t32path /home/uif24704/t32 --target makena
Python not detected in PATH. Attempting to add python executable path to PATH
Added Python directory /usr/bin to PATH
Selected target: makena
Selected session: None
Traceback (most recent call last):
File "t32start.py", line 847, in <module>
generate_buildinfo()
File "t32start.py", line 318, in generate_buildinfo
tmpfile = os.getenv('TEMP') + os.sep + cmmfilename
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

note: i have already set the TEMP path

Uwe Honekamp
  • 2,478
  • 1
  • 17
  • 15
  • It's telling you what the error is. The script you're trying to run is trying to add `None` to a `str`. What do you see when you run `echo $TEMP` in your shell? – Abirbhav G. Oct 13 '22 at 09:38
  • You may have _set_ `TEMP`, but did you _export_ it? If you just assign it it's a regular shell variable but not an environment variable; only environment variables are copied to subprocesses. (BTW, the standard name for a variable describing where to put temporary files is `TMPDIR`, not `TEMP`) – Charles Duffy Jan 21 '23 at 15:55

2 Answers2

0

It appears that variable cmmfilename is unset therefore causes and error when you are joining it with the string values. You should provide the code on how you call this Python script and how this script parses these arguments. For example: python main.py --filename="/sample_dir" and parser.add_argument("--filename", help="Working directory.").

You may also want to lookup on how to provide and read command line arguments (for example, see this question) as there are multiple ways in doing so.

Karolis
  • 255
  • 3
  • 15
0

Replace the following in t32start.py line 318

tmpfile = os.getenv('TEMP') + os.sep + cmmfilename

with

import tempfile
tmpfile = tempfile.gettempdir() + os.sep + cmmfilename

This uses a more generic cross-platform approach to getting the temporary directory. In the current code, os.getenv('TEMP') returns None which cannot be concatenated with the trailing string.

MiaPlan.de
  • 102
  • 8