Page 1 of 1

IndexError: tuple index out of range on a single post

Published: July 2, 2020 - 10:27 AM
by jlatieule
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.

Re: IndexError: tuple index out of range on a single post

Published: July 2, 2020 - 10:29 AM
by jlatieule
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?

Re: IndexError: tuple index out of range on a single post

Published: July 2, 2020 - 2:21 PM
by jlatieule
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)

Re: IndexError: tuple index out of range on a single post

Published: July 2, 2020 - 5:29 PM
by sfonteneau
Let's say `ignore_errors` will also catch a deletion error...

Testing for the folder's presence is preferable.

Re: IndexError: tuple index out of range on a single post

Published: July 3, 2020 - 2:18 PM
by jlatieule
Dumb question: why isn't this test included in the function?

Re: IndexError: tuple index out of range on a single post

Published: July 3, 2020 - 2:57 PM
by sfonteneau
We could indeed add an option to the function; there's no particular reason why not