Hi
Need help with my python functions
Where or How can I put def get_startupapps_path(): function in def install(): ?
so that when program copy it self to windows homdir,it will be start my ipScript every time at windows startup.Becuse my machine has dynamisk IP-adress.

import sys
import os
import getpass
import platform
import shutil

HOME = os.path.join(os.environ['HOMEDRIVE'], os.environ['HOMEPATH'])

def get_startupapps_path():
    user = getpass.getuser()
    if platform.release() == '7':
        return 'C:\Users\%s\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\ ' % user
    elif platform.release().lower() == 'xp':
        return 'C:\Documents and Settings\%s\Start Menu\Programs\Startup\ ' % user




def install():
    path = sys.argv[0]  # get path to script
    head, tail = os.path.split(path)  # return dir and file name
    shutil.copy(path, HOME)  # copy executable to %LOCALAPPDATA%
    executable = os.path.join(HOME, tail)
    head, tail = os.path.split(sys.argv[0])
    if HOME != head:
        install()

    #get_startupapps_path()

I would just add both directories to the PYTHONPATH variable in .bashrc. You can also add something like
export PYTHONSTARTUP=$HOME/.pythonstartup
to .bashrc to execute a given file when python starts.

Edit: Sorry, I see now from the "7" and "xp" that you are probably using a windows OS, but am going to leave the reply for any future searchers

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.