doccaz / scc-tools

A set of simple tools to interact with SUSE Customer Center (SCC)
MIT License
13 stars 1 forks source link

CSV files being written without the archive name #21

Closed doccaz closed 2 years ago

doccaz commented 2 years ago

As reported by Ralph Roth:

ralph at p5520 in ~/Documents/Eigene_TechDox/HealthCheck/scc-tools on master [?]
$ ll
total 128K
drwxr-xr-x 3 ralph users  193 25. Nov 16:41 ./
drwxr-xr-x 3 ralph users 4,0K 25. Nov 15:57 ../
drwxr-xr-x 8 ralph users  163 25. Nov 15:56 .git/
-rw-r--r-- 1 ralph users 1,1K 25. Nov 15:56 LICENSE
-rw-r--r-- 1 ralph users 6,6K 25. Nov 15:56 README.md
-rw-r--r-- 1 ralph users  18K 25. Nov 16:41 vercheck-different-.csv
-rw-r--r-- 1 ralph users 2,2K 25. Nov 16:41 vercheck-notfound-.csv
-rw-r--r-- 1 ralph users  448 25. Nov 16:41 vercheck-unsupported-.csv
-rw-r--r-- 1 ralph users  45K 25. Nov 16:41 vercheck-uptodate-.csv
-rwxr-xr-x 1 ralph users  34K 25. Nov 15:56 vercheck.py*

The script was called with:

$ ./vercheck.py -d /home/ralph/Desktop/.../unpacked/scc_czdcpv-uxnfs204_211101_1146/

doccaz commented 2 years ago

The problem lies with dealing with a trailing backslash (if it exists):

>>> import os
>>> blah='/home/erico/Projetos/scc-tools/tests/scc_exogelvm11219_210311_0856/'
>>> blah.split(os.sep)[-1]
''
>>> blah.rstrip(os.sep).split(os.sep)[-1]
'scc_exogelvm11219_210311_0856'

We need to rstrip () the OS path separators from the end of the string, or else the split() will return empty.

roseswe commented 2 years ago

Thanks! Can confirm this is now fixed!