Page 1 of 1

[SOLVED] Network drive and installation

Published: October 10, 2019 - 10:38 AM
by Herzas
Hello everyone, I'm working on a new WAPT installation and for this one I'd like to avoid using a replication server. So I've chosen to create WAPT packages for my largest software programs. Something fairly simple like: `
def install():
cmd = '\\server_north\software_folder\large_software\setup.exe'`.
Of course, just like with my usual setup, I get that wonderful error message:
"The specified path could not be found."
So I discovered that: The WAPT service runs under a local system account (NT_Authority\System), and this account is complicated for network drives with my Samba domain controller.
So I tried WAPT's session setup function and, miraculously, it works.
Except, unfortunately, it only works if the user has access rights to that network location, and if it's open and they enter their password at least once.

So I have a starting point: with the command
cmd = 'net use * \\serveur_nord\dossierlogiciel\groslogiciel\ /USER:login mdp'
locally there is no problem but via wapt it gets stuck I must be missing a ' ' or a " "

Finally I am open to any suggestion that would allow me to do without these replication servers.

Re: Network drive and installation

Published: October 12, 2019 - 11:19 AM
by sfonteneau
Putting a password in plain text in a WAPT packet isn't ideal.

Do you absolutely want to do it via SMB?

I'd recommend setting up a small web server instead. Nginx, Apache, or something similar... and then use wget in your packet.

Re: Network drive and installation

Published: October 14, 2019 - 8:34 AM
by nliaudat

Code: Select all

import win32wnet

wnet_connect(host, username, password)
#dès la connexion établie, l'accès au dossier est possible.

def wnet_connect(host, username, password):
    unc = ''.join(['\\\\', host])
    try:
        win32wnet.WNetAddConnection2(0, None, unc, None, username, password)
    except Exception, err:
        if isinstance(err, win32wnet.error):
            # Disconnect previous connections if detected, and reconnect.
            if err[0] == 1219:
                win32wnet.WNetCancelConnection2(unc, 0, 0)
                return wnet_connect(host, username, password)
        raise err
You create a read-only wapt-install user on your software folder with no other access

An example of how to select the nearest server based on the gateway:

Code: Select all

def getdownloadserver():
    #### Get gateway and set depending server
    location = str(get_default_gateways()).split('.')[2]  ## third octet of gateway ip address

    if location == 0 : 
        return "10.0.0.X"
    elif location == 1 : 
        return "10.0.1.X"
    elif location == 2 : 
        return "10.0.2.X"
    else :
        return "10.0.0.X"

Re: Network drive and installation

Published: October 14, 2019 - 09:15
by sfonteneau
Remember to make a copy rather than launching the installer directly from the network drive. This avoids a number of problems