evertonstz/pynps

Index Error with Themes

singha95 opened this issue · 4 comments

I noticed that there is an error with the following function when downloading psv themes. I was able to fix this by creating a temp file in my theme folder. Please note I tried to fix the code myself so there may be a +/- difference in the lines in the errors.

Traceback (most recent call last):
  File "/usr/bin/pynps", line 8, in <module>
    sys.exit(cli_main())
  File "/usr/lib/python3.8/site-packages/pynps/cli/cli.py", line 582, in cli_main
    theme_folder_name = get_theme_folder_name(f"{DLFOLDER}/Extracted/bgdl/t/")
  File "/usr/lib/python3.8/site-packages/pynps/functions/functions.py", line 731, in get_theme_folder_name
    comp = list(range(1, a[-1] + 1))
IndexError: list index out of range

From what I can tell it caused by the following line because the list 'a' is empty:
comp = list(range(1, a[-1] + 1))

Hey! Sorry for being so late, didn't had much time to work in this app due to covid and sh*t. I'll take a look at the problem. I suppose you don't remember the exactly command you were using to get this bug, right? I can't seem to be able to reproduce it,

An example of what happened

[angad@angad-desktop ~]$ pynps  -c psv --themes "hyper"
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[SEARCH] here are the matches:
1) PSV | PCSE00661 | USA | Theme | Hyperdimension Neptunia Re;Birth3 - Custom Theme                                                                                                                                                [ 4.98 MiB]
2) PSV | PCSE00661 | USA | Theme | Hyperdimension Neptunia Re;Birth3 - CPU Custom Theme                                                                                                                                            [ 7.07 MiB]
3) PSV | PCSE00661 | USA | Theme | Hyperdimension Neptunia Re;Birth3 - CPU Candidate Custom Theme                                                                                                                                  [5.795 MiB]
4) PSV | PCSB00751 | EUR | Theme | Hyperdimension Neptunia ReBirth3 - Custom Theme                                                                                                                                                 [4.981 MiB]
5) PSV | PCSB00751 | EUR | Theme | Hyperdimension Neptunia ReBirth3 - CPU Custom Theme                                                                                                                                             [ 7.07 MiB]
6) PSV | PCSB00751 | EUR | Theme | Hyperdimension Neptunia ReBirth3 - CPU Candidate Custom Theme                                                                                                                                   [5.795 MiB]
7) PSV | PCSG00486 | JAP | Theme | Hyperdimension Neptune Re;Birth3 PS Vita Custom theme                                                                                                                                           [4.976 MiB]
Enter the number for what you want to download, you can enter multiple numbers using commas: 1                                                                                                                                                
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[SEARCH] you're going to download the following files:
1) PSV | PCSE00661 | USA | Theme | Hyperdimension Neptunia Re;Birth3 - Custom Theme                                                                                                                                                [ 4.98 MiB]
Download files? [y/n]: y                                                                                                                                                                                                                      
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[DOWNLOAD] Hyperdimension Neptunia Re;Birth3 - Custom Theme (US) [PCSE00661] for PSV
UP0031-PCSE00661_00-PSVITATHEME00001_bg_1_15e651f1b7c6d64b2 100%[=========================================================================================================================================>]   4.98M  2.55MB/s    in 2.0s    
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[CHECKSUM] downloaded is not corrupted!
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/bin/pynps", line 8, in <module>
    sys.exit(cli_main())
  File "/usr/lib/python3.8/site-packages/pynps/cli/cli.py", line 582, in cli_main
    theme_folder_name = get_theme_folder_name(f"{DLFOLDER}/Extracted/bgdl/t/")
  File "/usr/lib/python3.8/site-packages/pynps/functions/functions.py", line 730, in get_theme_folder_name
    comp = list(range(1, a[-1] + 1))
IndexError: list index out of range

How my themes folder looks when this happens:

[angad@angad-desktop ~]$ ls -ltr -a /run/media/angad/DATA/pyNPS/Extracted/bgdl/t/
total 0
drwxrwxrwx 1 root root  0 Feb 24 14:22 ..
drwxrwxrwx 1 root root 48 Apr  1 14:35 .

How I fixed the issue:

[angad@angad-desktop ~]$ cd /run/media/angad/DATA/pyNPS/Extracted/bgdl/t/
[angad@angad-desktop t]$ touch temp.txt 
[angad@angad-desktop t]$ ls -ltr 
total 0
-rwxrwxrwx 1 root root 0 Apr  1 14:47 temp.txt
[angad@angad-desktop t]$ ls -ltra
total 0
drwxrwxrwx 1 root root   0 Feb 24 14:22 ..
-rwxrwxrwx 1 root root   0 Apr  1 14:47 temp.txt
drwxrwxrwx 1 root root 152 Apr  1 14:47 .

Thank you! I've located the error, it seems I've forgot to test the case were the folder don't exist or if it exist and has no extracted themes inside. Anyways, it's solved :)