IndexError: tuple index out of range on a single post

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
jlatieule
Messages: 59
Registration: July 3, 2019 - 9:18 AM

July 2, 2020 - 10:27

Good morning,


I'm getting an "IndexError: tuple index out of range" installation error on a package, but only on one machine. It works fine on other machines running Windows 10 and Windows 7 (x86 and x64).
When in doubt, I reinstalled the agent after purging everything.

Here's the script running with wapt 1.7.4... perhaps the problem is related to session_setup():
By the way, if you want to add options for stamps/signatures to your tis-foxit package, what I added works well.

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *
import requests
import platform
try:
    import bs4 as BeautifulSoup
except:
    import BeautifulSoup

uninstallkey = []

# Declaring specific app values (TO CHANGE)
bin_name_string = 'FoxitReader_%s_Setup.exe'
silent_args_string = '/ForceInstall /VERYSILENT DESKTOP_SHORTCUT="0" MAKEDEFAULT="1" VIEWINBROWSER="0" LAUNCHCHECKDEFAULT="1" AUTO_UPDATE="0" /passive /norestart /LANG=%s'
app_uninstallkey = 'Foxit Reader_is1'


def install():
    # Specific app values
    package_version = control.version.split('-',1)[0]
    lang = get_language()

    # Installing the package
    install_exe_if_needed(bin_name_string % package_version
        ,silentflags=silent_args_string % lang
        ,key=app_uninstallkey
        ,min_version=package_version)

    registry_setstring(HKEY_LOCAL_MACHINE,r'SOFTWARE\Policies\Explorer\DisallowRun','foxit_updater','FoxitReaderUpdater.exe')

    remove_desktop_shortcut('Foxit Reader')

    # Purge des anciens modèles
    remove_tree(r'c:\ProgramData\Foxit Software\Signature')
    remove_tree(r'c:\ProgramData\Foxit Software\UserStamps')

    # Copie du modèle de signature Domitia
    copytree2('Signature',r'c:\ProgramData\Foxit Software\Signature')
    # Copie du modèle de tampon
    copytree2('UserStamps',r'c:\ProgramData\Foxit Software\UserStamps')


def session_setup():
    print('Disabling auto update check')

    # Specific app values
    package_version = control.version.split('-',1)[0]
    split_package_version = package_version.split('.')
    short_package_version = '%s.%s'% (split_package_version[0],split_package_version[1])

    registry_setstring(HKEY_CURRENT_USER,r'Software\Foxit Software\Foxit Reader %s\plugins\Updater' % short_package_version,'UpdateMode','0')

    updater_path = makepath(user_appdata,'Foxit Software','Addon','Foxit Reader','FoxitReaderUpdater.exe')
    if isfile(updater_path):
        remove_file(updater_path)

    #Ordinateur\HKEY_CURRENT_USER\Software\Foxit Software\Foxit Reader 10.0\Preferences\Registration
    #bShowRegisterDlg = 0

    # Désactivation enregistrement à la première utilisation
    registry_setstring(HKEY_CURRENT_USER, r"Software\Foxit Software\Foxit Reader 10.0\Preferences\Registration",'bShowRegisterDlg','0', type=REG_SZ)

    # Intégration de la signature Domitia
    mkdirs(makepath(user_appdata,'Foxit Software','Foxit Reader','Signature'))
    filecopyto(r'c:\ProgramData\Foxit Software\Signature\style.foxitdata',makepath(user_appdata,'Foxit Software','Foxit Reader','Signature'))

    # Intégration du modèle de tampon Domitia
    mkdirs(makepath(user_appdata,'Foxit Software','Foxit Reader','Stamps','UserStamps'))
    filecopyto(r'c:\ProgramData\Foxit Software\UserStamps\FXSvlmkiquvspwvgxy.pdf',makepath(user_appdata,'Foxit Software','Foxit Reader','Stamps','UserStamps'))

    # Suppression d'ancien modèle de tampon
    remove_file(makepath(user_appdata,'Foxit Software','Foxit Reader','Stamps','UserStamps','FXSusgzziovrftavgp.pdf'))


def update_package():
    print('Download/Update package content from upstream binary sources')

    # Getting proxy informations from WAPT settings
    proxy = {}
    if platform.system()=='Windows' and isfile(makepath(user_local_appdata(),'waptconsole','waptconsole.ini')):
        proxywapt = inifile_readstring(makepath(user_local_appdata(),'waptconsole','waptconsole.ini'),'global','http_proxy')
        if proxywapt :
            proxy = {'http':proxywapt,'https':proxywapt}

    # Specific app values
    app_name = control.name
    url = 'https://www.foxitsoftware.com/pdf-reader/version-history.php'

    # Getting latest version from official website
    page = requests.get(url,headers={'User-Agent':'Mozilla/5.0 (Windows NT 6.1; Win64; x64)'}).text
    bs = BeautifulSoup.BeautifulSoup(page)
    #bs = BeautifulSoup.BeautifulSoup(page,features="html.parser") # For bs4 only
    bs_raw_string = str(bs.find('h3').text)
    version = bs_raw_string.replace('Version ','')

    url_dl = 'https://www.foxitsoftware.com/downloads/latest.php?product=Foxit-Reader&platform=Windows&package_type=exe&language=French&version=%s' % version
    latest_bin = bin_name_string % version

    print('Latest ' + app_name + ' version is: ' + version)
    print('Download url is: ' + url_dl)

    # Downloading latest binaries
    if not isfile(latest_bin):
        print('Downloading: ' + latest_bin)
        wget(url_dl,latest_bin,proxies=proxy)

        # Get version from file
        version_from_file = get_file_properties(latest_bin)['ProductVersion']
        if version != version_from_file and version_from_file != '':
            version = version_from_file
            old_latest_bin = latest_bin
            latest_bin = bin_name_string % version
            if isfile(latest_bin):
                remove_file(latest_bin)
            os.rename(old_latest_bin,latest_bin)

		# Change version of the package
        pe = PackageEntry().load_control_from_wapt('.')
        pe.version = '%s-%s'%(version,int(pe.version.split('-',1)[1])+1)
        pe.save_control_to_wapt('.')
        print('Changing version to ' + pe.version + ' in WAPT\\control')
        print('Update package done. You can now build-upload your package')
    else:
        print('This package is already up-to-date')

    # Deleting outdated binaries
    for bin_in_dir in glob.glob('*.exe') or glob.glob('*.msi'):
        if bin_in_dir != latest_bin :
            print('Outdated binary: ' + bin_in_dir + ' Deleted')
            remove_file(bin_in_dir)
Additionally, here's the debugging command: `wapt-get install ophlm-foxit -ldebug`

2020-07-02 10:17:10,618 DEBUG Default encoding: ascii
2020-07-02 10:17:10,618 DEBUG Setting encoding for stdout and stderr to cp850
2020-07-02 10:17:10,624 DEBUG Python path ['C:\\Program Files (x86)\\wapt', 'C:\\Program Files (x86)\\wapt', 'C:\\Program
Files (x86)\\wapt\\python27.zip', 'C:\\Program Files (x86)\\wapt\\DLLs', 'C:\\Program Files (x86)\\wapt\\lib', 'C:\\Pr
ogram Files (x86)\\wapt\\lib\\plat-win', 'C:\\Program Files (x86)\\wapt\\lib\\lib-tk', 'C:\\Program Files (x86)\\wapt',
'C:\\Program Files (x86)\\wapt\\lib\\site-packages', 'C:\\Program Files (x86)\\wapt\\lib\\site-packages\\pywin32-223-py2
.7-win32.egg']
2020-07-02 10:17:10,625 INFO Using local waptservice configuration C:\Program Files (x86)\wapt\wapt-get.ini
2020-07-02 10:17:10,625 DEBUG Config file: C:\Program Files (x86)\wapt\wapt-get.ini
Using config file: C:\Program Files (x86)\wapt\wapt-get.ini
2020-07-02 10:17:10,628 DEBUG Thread 1480 is connecting to wapt db
2020-07-02 10:17:10,694 DEBUG Using host certificate C:\Program Files (x86)\wapt\private\4C4C4544-0048-5010-8039-B5C04F3
33332.pem for repo global auth
2020-07-02 10:17:10,723 DEBUG Thread 1480 is connecting to wapt db
2020-07-02 10:17:10,723 DEBUG DB Start transaction
2020-07-02 10:17:10,723 DEBUG DB commit
2020-07-02 10:17:10,782 DEBUG Using host certificate C:\Program Files (x86)\wapt\private\4C4C4544-0048-5010-8039-B5C04F3
33332.pem for repo wapt auth
2020-07-02 10:17:10,901 DEBUG Using host certificate C:\Program Files (x86)\wapt\private\4C4C4544-0048-5010-8039-B5C04F3
33332.pem for repo wapt-host auth
2020-07-02 10:17:10,930 INFO User Groups:[]
2020-07-02 10:17:10,930 DEBUG WAPT base directory: C:\Program Files (x86)\wapt
2020-07-02 10:17:10,930 DEBUG Package cache dir: C:\Program Files (x86)\wapt\cache
2020-07-02 10:17:10,930 DEBUG WAPT DB Structure version;: 20190606
2020-07-02 10:17:10,930 DEBUG Checking if old install in progress
2020-07-02 10:17:10,940 DEBUG reset stalled install_status in database
installing WAPT packages ophlm-foxit
2020-07-02 10:17:10,974 DEBUG Loading ssl context with cert C:\Program Files (x86)\wapt\private\4C4C4544-0048-5010-8039-
B5C04F333332.crt and key C:\Program Files (x86)\wapt\private\4C4C4544-0048-5010-8039-B5C04F333332.pem
2020-07-02 10:17:11,178 INFO Use cached package file from C:\Program Files (x86)\wapt\cache\ophlm-foxit_10.0.0.35798-1
1_PREPROD.wapt
2020-07-02 10:17:11,384 DEBUG Stores cert chain check in cache
2020-07-02 10:17:11,385 DEBUG Downloaded: {'downloaded': [], 'skipped': [u'C:\\Program Files (x86)\\wapt\\cache\\ophlm-
foxit_10.0.0.35798-11_PREPROD.wapt'], 'errors': [], 'packages': [PackageEntry(u'ophlm-foxit',u'10.0.0.35798-11' maturity
=u'PREPROD')]}
Installing ophlm-foxit(=10.0.0.35798-11)
2020-07-02 10:17:11,387 INFO Register start of install C:\Program Files (x86)\wapt\cache\ophlm-foxit_10.0.0.35798-11_PRE
PROD.wapt as user latijoel to local DB with params {}
2020-07-02 10:17:11,387 INFO Interactive user:latijoel, usergroups []
2020-07-02 10:17:11,588 INFO Status: Installing package ophlm-foxit version 10.0.0.35798-11 ...
2020-07-02 10:17:11,588 DEBUG DB Start transaction
2020-07-02 10:17:11,588 DEBUG DB commit
2020-07-02 10:17:11,631 DEBUG DB Start transaction
2020-07-02 10:17:11,634 DEBUG DB commit
2020-07-02 10:17:11,674 INFO Control data for package C:\Program Files (x86)\wapt\cache\ophlm-foxit_10.0.0.35798-11_PREP
ROD.wapt verified by certificate SSLCertificate cn=domitia
2020-07-02 10:17:11,674 INFO Installing package C:\Program Files (x86)\wapt\cache\ophlm-foxit_10.0.0.35798-11_PREPROD.wa
pt
2020-07-02 10:17:11,678 INFO Unzipping package C:\Program Files (x86)\wapt\cache\ophlm-foxit_10.0.0.35798-11_PREPROD.wap
t to directory c:\users\latijoel\appdata\local\temp\waptxdg9ol
2020-07-02 10:17:11,993 INFO Package has a setup.py, code signing certificate is required.
2020-07-02 10:17:11,996 DEBUG Certificate {'countryName': u'FR', 'commonName': u'domitia', 'emailAddress': u'serviceinfo
rmatique@domitia-habitat.fr', 'organizationName': u'Domitia Habitat', 'localityName': u'Narbonne'} is trusted by root CA
domitia
2020-07-02 10:17:11,997 DEBUG Checking signature with SSLCertificate cn=domitia
2020-07-02 10:17:12,000 DEBUG OK with SSLCertificate cn=domitia
2020-07-02 10:17:12,000 INFO Package issued by {'countryName': u'FR', 'commonName': u'domitia', 'emailAddress': u'servic
einformatique@domitia-habitat.fr', 'organizationName': u'Domitia Habitat', 'localityName': u'Narbonne'}
2020-07-02 10:17:12,325 INFO Unzipped files verified by certificate SSLCertificate cn=domitia
2020-07-02 10:17:12,325 DEBUG Removing existing persistent dir C:\Program Files (x86)\wapt\private\persistent\883da6a5-8
ae2-4477-b9e9-bd9b66350454
2020-07-02 10:17:12,328 INFO sourcing install file c:\users\latijoel\appdata\local\temp\waptxdg9ol\setup.py
2020-07-02 10:17:12,328 DEBUG Import source c:\users\latijoel\appdata\local\temp\waptxdg9ol\setup.py as __waptsetup_qkz8
8wxt4v__
2020-07-02 10:17:12,338 INFO Install parameters: {}
2020-07-02 10:17:12,339 DEBUG DB Start transaction
2020-07-02 10:17:12,342 DEBUG DB commit
2020-07-02 10:17:12,489 INFO executing install script
2020-07-02 10:17:12,503 DEBUG DB Start transaction
2020-07-02 10:17:12,505 DEBUG DB commit
Exe setup FoxitReader_10.0.0.35798_Setup.exe already installed. Skipping
2020-07-02 10:17:12,542 INFO File C:\Users\Public\Desktop\Foxit Reader.lnk doesn't exist, so not removed
2020-07-02 10:17:12,543 DEBUG Cleaning package tmp dir
2020-07-02 10:17:12,559 DEBUG DB Start transaction
2020-07-02 10:17:12,561 DEBUG DB commit
2020-07-02 10:17:12,607 DEBUG DB Start transaction
2020-07-02 10:17:12,608 DEBUG DB commit
2020-07-02 10:17:12,651 DEBUG DB Start transaction
2020-07-02 10:17:12,653 DEBUG DB commit
2020-07-02 10:17:12,707 DEBUG Removing module: __waptsetup_qkz88wxt4v__, refcnt: 4
2020-07-02 10:17:12,776 DEBUG Checking availability of host packages "[PackageEntry(u'4C4C4544-0048-5010-8039-B5C04F3333
32',u'4' )]"
2020-07-02 10:17:12,778 DEBUG Checking if 4C4C4544-0048-5010-8039-B5C04F333332(=4) is installed/outdated
2020-07-02 10:17:12,836 DEBUG store status in DB
2020-07-02 10:17:12,838 DEBUG DB Start transaction
2020-07-02 10:17:12,838 DEBUG DB commit
2020-07-02 10:17:12,891 INFO Status:
2020-07-02 10:17:12,894 DEBUG DB Start transaction
2020-07-02 10:17:12,894 DEBUG DB commit
2020-07-02 10:17:12,937 CRITICAL Package ophlm-foxit [x64_fr_PROD,PREPROD] not installed due to errors: IndexError: tuple
index out of range
FATAL ERROR: IndexError: tuple index out of range
Traceback (most recent call last):
File "
File "
File "C:\Program Files (x86)\wapt\common.py", line 4855, in install
force=force
File "C:\Program Files (x86)\wapt\common.py", line 3934, in install_wapt
raise e
IndexError: tuple index out of range
Exception at 00441CD4: EPyIndexError:
exceptions.IndexError: tuple index out of tidy.
System and Network Administrator at Domitia Habitat
jlatieule
Messages: 59
Registration: July 3, 2019 - 9:18 AM

July 2, 2020 - 10:29

This shows that posting logs and reviewing each step of a script can help to find the cause of the problem

The problem occurs with the following commands if the folders do not exist

Code: Select all

    # Purge des anciens modèles
    remove_tree(r'c:\ProgramData\Foxit Software\Signature')
    remove_tree(r'c:\ProgramData\Foxit Software\UserStamps')
Is it mandatory to check for the existence of the files to be deleted?
Last edited by jlatieule on July 2, 2020 - 2:21 PM, edited 1 time.
System and Network Administrator at Domitia Habitat
jlatieule
Messages: 59
Registration: July 3, 2019 - 9:18 AM

July 2, 2020 - 2:21 PM

Unless we ignore the errors... If that's the case, a small example using commonly used functions would be perfect

Code: Select all

    # Purge des anciens modèles
    remove_tree(r'c:\ProgramData\Foxit Software\Signature', ignore_errors=True)
    remove_tree(r'c:\ProgramData\Foxit Software\UserStamps', ignore_errors=True)
System and Network Administrator at Domitia Habitat
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

July 2, 2020 - 5:29 PM

Let's say `ignore_errors` will also catch a deletion error...

Testing for the folder's presence is preferable.
jlatieule
Messages: 59
Registration: July 3, 2019 - 9:18 AM

July 3, 2020 - 2:18 PM

Dumb question: why isn't this test included in the function?
System and Network Administrator at Domitia Habitat
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

July 3, 2020 - 2:57 PM

We could indeed add an option to the function; there's no particular reason why not
Locked