Smart questions
Smart answers
Smart people
Join Tek-Tips Forums

Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

YoungManRiver (IS/IT--Management) (OP)
13 Mar 08 2:37

I downloaded the OpenEMM (Linux & Windows) to install.

The Windows version uses Python as the Installer and the programmer for this installer made some bad assumptions about the installations.

I posted a run-down of the install problems at:

First bad assumption was that all installs would be on the "C:" drive.  This prefaces and leads to all the other problems in the install code.

Second bad assumption is that this is native AMP (Apache, MySQL & PHP) install, so Reg Key in the Windows registry will look for standard naming.

My machine uses Wamp, which is successfully installed, but Wamp does not use the same key names in the Windows Registry that Apache, MySQL and PHP (AMP) use, therefore the programmer needed a list, not a single text string to use for searching in the registry.  This also would apply to persons using WinAmp as their chosen AMP install tool for Windows.

I know absolutely nothing about Python, but know enough other languages (25) that I thought I would try to muddle through this to solve these problems, but right now too busy so could use some assistance.

All help here greatly appreciated!!


YoungManRiver (IS/IT--Management) (OP)
17 Mar 08 21:14

Opened a thread at:

on this as I'm noobie on Python, so will need all the help I can get!

YoungManRiver (IS/IT--Management) (OP)
21 Mar 08 14:09

Still no feedback from Python.

YoungManRiver (IS/IT--Management) (OP)
23 May 08 21:26

Hum! Seem Python forum is usless!  Posted my plea for help there in Mar and now it is May.

Some sites just don't have what they say they have.

YoungManRiver (IS/IT--Management) (OP)
23 May 08 23:23

Oh wasn't talking about this Python Forum, but the official one in the link.

Here's where I'm at in my code:


#       -*- python -*-
* The contents of this file are subject to the Common Public Attribution
* License Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* The License is based on the Mozilla
* Public License Version 1.1 but Sections 14 and 15 have been added to cover
* use of software over a computer network and provide for limited attribution
* for the Original Developer. In addition, Exhibit A has been modified to be
* consistent with Exhibit B.
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is OpenEMM.
* The Original Developer is the Initial Developer.
* The Initial Developer of the Original Code is AGNITAS AG. All portions of
* the code written by AGNITAS AG are Copyright (c) 2007 AGNITAS AG. All Rights
* Reserved.
* Contributor(s): AGNITAS AG.
import  sys, os, time
def show (s):
        sys.stderr.write (s)
        sys.stderr.flush ()
def prompt (prmt):
        if prmt:
                show (prmt)
        return sys.stdin.readline ().strip ()
def error (msg):
        show (msg + '\n')
        prompt ('[press return]')
        sys.exit (1)
def addpath (path):
        parts = os.environ['PATH'].split (os.path.pathsep)
        if not path in parts:
                parts.insert (0, path)
                os.environ['PATH'] = os.path.pathsep.join (parts)
show ('Starting up .. ')
# try:
homedrive = os.getcwd()
if homedrive is None:
        homedrive = os.environ['HOMEDRIVE']
#except KeyError:
#        homedrive = 'C:'
home = homedrive + os.path.sep + 'OpenEMM'
#show (home)
# home = 'E:\Mail\OpenEMM'
# home = 'D:\Mail\OpenEMM'
#if not os.path.isdir (home):
#        guess = None
#        for disk in 'CDEFGHIJKLMNOPQRSTUVWXYZ':
#                temp = disk + ':' + os.path.sep + 'OpenEMM'
#                if os.path.isdir (temp):
#                        guess = temp
#                        break
#        if guess is None:
#                error (' Failed to find homedir "%s"' % home)
#        home = guess
show ('home is %s .. ' % home)
os.environ['HOME'] = home
binhome = home + os.path.sep + 'bin'
show (' binhome is %s .. ' % binhome)
addpath (binhome)
schome = binhome + os.path.sep + 'scripts'
os.environ['PYTHONPATH'] = schome
if not schome in sys.path:
        sys.path.append (schome)
addpath (schome)
os.environ['LC_ALL'] = 'C'
os.environ['LANG'] = 'en_US.ISO8859_1'
os.environ['NLS_LANG'] = 'american_america.UTF8'
resin = binhome + os.path.sep + 'httpd.exe'

#impagn = binhome + os.path.sep + 'agn'
import agn
#dirlist = dir(agn)
#show (dirlist)
show ('found codebase .. ')
# Check for working database
#if not 'DBase' in dir (agn):
#       error ('No database module found')
# add python to path
addpath (agn.pythonpath)
# find jdk
jdkkey = r'SOFTWARE\JavaSoft\Java Development Kit'
version = agn.winregFind (jdkkey, 'CurrentVersion')
#show ('Java Version => ' + version)
#if version is None:
#       error ('JDK not found')
#javahome = agn.winregFind (jdkkey + '\\' + version, 'JavaHome')
javahome = 'C:\Program Files\Java\jre1.6.0_02'
addpath (javahome + os.path.sep + 'bin')
# find mysql
#mskey = r'SOFTWARE\MySQL AB\MySQL Server 5.0'
#mysqlhome = agn.winregFind (mskey, 'Location')
mysqlhome = 'E:\Program Files\wamp\mysql'
if not mysqlhome is None:
        addpath (mysqlhome + os.path.sep + 'bin')
# build additional CLASSPATH
cp = []
libdir = home + os.path.sep + 'lib'
olibdir = libdir + os.path.sep + 'openemm'
cp = [olibdir]
for fname in os.listdir (olibdir):
        if fname.endswith ('.jar'):
                cp.append (olibdir + os.path.sep + fname)
# Optional commands
if len (sys.argv) > 1:
        os.chdir (home)
        if sys.argv[1] == 'setup':
                show ('setup:\n')
#               show ('Setup database, please enter the super user password defined during MySQL instllation:\n')
#                deflgstr = 'mysqladmin -u root -p create openemm'
#                deflgstr = "'E:\Program Files\wamp\mysql\bin\mysql' -u root"
#                if os.system (deflgstr):
#                        error ('Failed to create database')
#                show ('Database created, now setting up initial data, please enter again your databae super user password:\n')
#                if os.system ('mysql -u root -p -e "source USR_SHARE\\openemm.sql" openemm'):
#                        error ('Failed to setup database')
#                show ('Database setup completed.\n')
        if sys.argv[1] in ('setup', 'config'):
                db = agn.DBase ()
                if not db:
                        error ('Failed to setup database connection')
                i = db.newInstance ()
                if not i:
                        error ('Failed to connect to database')
                rdir = None
                mailloop = None
                for r in i.query ('SELECT rdir_domain, mailloop_domain FROM company_tbl WHERE company_id = 1'):
                        rdir = r[0]
                        mailloop = r[1]
                if sys.argv[1] == 'config':
                        show ('config:\n')
                if rdir is None: rdir = ''
                nrdir = prompt ('Enter redirection domain [%s]: ' % rdir)
                if not nrdir: nrdir = rdir
                if mailloop is None: mailloop = ''
                nmailloop = prompt ('Enter mailloop domain [%s]: ' % mailloop)
                if not nmailloop: nmailloop = mailloop
                if nrdir != rdir or nmailloop != mailloop:
                        i.update ('UPDATE company_tbl SET rdir_domain = :rdir, mailloop_domain = :mailloop WHERE company_id = 1',
                                  { 'rdir': nrdir, 'mailloop': nmailloop })
                        db.commit ()
                i.close ()
                db.close ()
                sfname = 'conf' + os.path.sep + 'smart-relay'
                        fd = open (sfname)
                        sr = ().strip ()
                        fd.close ()
                except IOError:
                        sr = ''
                show ('Smart mail relay - optional parameter. Specifiy this, if you want to send\n')
                show ('all your outgoing mail via one deticated server (e.g. your ISP mail server.)\n')
                show ('You may add login information in the form <username>:<password>@<relay> if\n')
                show ('the smart relay requires authentication.\n')
                nsr = prompt ('Enter smart relay (or just - to remove existing one) [%s]: ' % sr)
                if nsr:
                        if nsr == '-':
                                        os.unlink (sfname)
                                except OSError:
                        elif nsr != sr:
                                fd = open (sfname, 'w')
                                fd.write ('%s\n' % nsr)
                                fd.close ()
                prompt ('Congratulations, %s completed! [return] ' % sys.argv[1])
        elif sys.argv[1] == 'update':
                show ('update:\n')
                db = agn.DBase ()
                if not db:
                        error ('Failed to setup database connection')
                i = db.newInstance ()
                if not i:
                        error ('Failed to connect to database')
                table = '__version_tbl'
                found = False
                for r in i.query ('SHOW TABLES'):
                        if r[0] == table:
                                found = True
                if not found:
                        version = '5.1.0'
                        tempfile = 'version.sql'
                        fd = open (tempfile, 'w')
                        fd.write ('CREATE TABLE %s (version varchar(50));\n' % table)
                        fd.close ()
                        show ('Database update, please enter your database super user password now\n')
                        st = os.system ('mysql -u root -p -e "source %s" openemm' % tempfile)
                                os.unlink (tempfile)
                        except OSError:
                        if st:
                                error ('Failed to setup database')
                        i.update ('INSERT INTO %s VALUES (:version)' % table, {'version': version })
                        db.commit ()
                        version = None
                        for r in i.query ('SELECT version FROM %s' % table):
                                version = r[0]
                        if version is None:
                                error ('Found version table, but no content in table')
                        elif version == '5.1.0':
                                version = '5.1.1'
                        elif version == '5.1.1':
                                version = '5.3.0'
                ans = prompt ('It looks like your previous version is "%s", is this corrent? [no] ' % version)
                if not ans or not ans[0] in 'Yy':
                        error ('Version conflict!')
                curversion = '5.3.2'
                updates = []
                for fname in os.listdir ('USR_SHARE'):
                        if fname.endswith ('.usql'):
                                base = fname[:-5]
                                parts = base.split ('-')
                                if len (parts) == 2:
                                        updates.append ([parts[0], parts[1], 'USR_SHARE\\%s' % fname])
                seen = []
                while version != curversion:
                        found = False
                        for upd in updates:
                                if upd[0] == version and not upd[2] in seen:
                                                fd = open (upd[2])
                                                cont = ()
                                                fd.close ()
                                                isEmpty = (len (cont) == 0)
                                        except IOError:
                                                isEmpty = False
                                        if not isEmpty:
                                                show ('Database upgrade from %s to %s, please enter your super user password now\n' % (version, upd[1]))
                                                if os.system ('mysql -u root -p -e "source %s" openemm' % upd[2]):
                                                        error ('Failed to update')
                                                show ('No database update from %s to %s required\n' % (version, upd[1]))
                                        version = upd[1]
                                        seen.append (upd[2])
                                        i.update ('UPDATE %s SET version = :version' % table, {'version': version})
                                        db.commit ()
                                        found = True
                        if not found:
                                error ('No update from %s to %s found' % (version, curversion))
                i.close ()
                db.close ()
                show ('Update to version %s finished! You may start config.bat now to see\n' % version)
                prompt ('if there are some new things to setup [return] ')
                error ('Unknown option %s' % sys.argv[1])
        sys.exit (0)

db = agn.DBase ()
if not db:
        error ('Failed to setup database connection')
i = db.newInstance ()
if not i:
        error ('Failed to connect to database')
i.close ()
db.close ()
show ('found database.\n')
# remove potential stale files
sessions = os.path.sep.join ([home, 'webapps', 'openemm', 'htdocs', 'WEB-INF', 'sessions'])
fnames = [agn.winstopfile]
if os.path.isdir (sessions):
        for fname in os.listdir (sessions):
                fnames.append (sessions + os.path.sep + fname)
        for fname in fnames:
                        os.unlink (fname)
#                       show ('Removed stale file %s.\n' % fname)
                except WindowsError:
# change to home directory
os.chdir (home)
def pystart (cmd):
        args = cmd.split ()
        args.insert (0, agn.pythonbin)
        return os.spawnv (os.P_NOWAIT, args[0], args)

def resinexec (module, what):
        lpath = home + os.path.sep + 'var' + os.path.sep + 'log' + os.path.sep
        lout = lpath + module + '_stdout.log'
        lerr = lpath + module + '_stderr.log'
        cmd = '%s -conf %s%sconf%s%s.conf' % (resin, home, os.path.sep, os.path.sep, module)
        cmd += ' -verbose'
        cmd += ' -jvm-log %s%s.log' % (lpath, module)
        cmd += ' -resin-home %s' % home
        cmd += ' -server %s' % module
#       cmd += ' %s' % what
        args = cmd.split ()
        env = os.environ.copy ()
        env['LANG'] = 'en_US.ISO8859_1'
        env['CLASSPATH'] = os.path.pathsep.join (cp)
        saveout = os.dup (1)
        saveerr = os.dup (2)
        os.close (1)
        os.close (2) (lout, os.O_WRONLY | os.O_APPEND | os.O_CREAT, 0666) (lerr, os.O_WRONLY | os.O_APPEND | os.O_CREAT, 0666)
        pid = os.spawnve (os.P_NOWAIT, args[0], args, env)
        os.close (1)
        os.close (2)
        os.dup (saveout)
        os.dup (saveerr)
        os.close (saveout)
        os.close (saveerr)
        return pid
def resinstart (module):
        return resinexec (module, 'start')
def resinstop (module):
        return resinexec (module, 'stop')
p_upd = pystart (schome + os.path.sep + ' account bounce')
if p_upd == -1:
        error ('Failed to start update process')
p_dst = pystart (schome + os.path.sep + '')
if p_dst == -1:
        error ('Failed to start pickdist process')
p_bav = pystart (schome + os.path.sep + '')
if p_bav == -1:
        error ('Failed to start bav-update process')
p_sem = pystart (schome + os.path.sep + '')
if p_sem == -1:
        error ('Failed to start semu process')
p_con = resinstart ('console')
if p_con == -1:
        error ('Failed to start console')
time.sleep (2)
p_rdir = resinstart ('redirection')
if p_rdir == -1:
        error ('Failed to start redirection')
#time.sleep (2)
prompt ('Running, press return for termination: ')
show ('Please press the Resin QUIT buttons to terminate java processes.\n')
#resinstop ('redirection')
#time.sleep (2)
#resinstop ('console')
show ('Signal termination to enviroment\n')
open (agn.winstopfile, 'w').close ()
time.sleep (3)
prompt ('Finished, press [return] ')
show ('(window closes on final termination of all processes) ')
time.sleep (2)
You can see I had to put in:


homedrive = os.getcwd()
to get the current directory and then comment out the testing that followed as it was looking for "X:\OpenEMM" only and would not accept any other directory structure.

Anyway this gets to line 83 then blows.  Says it can't find or use the agn module in


import agn
but the file is there unless it is looking for compiled version of the "" file, but this is usually not the case, but I also have the "agn.pyc" compiled file, so something is not setting right in the "path" assignments, at least that my assesment.

YoungManRiver (IS/IT--Management) (OP)
30 May 08 18:46
Any inputs or help?
YoungManRiver (IS/IT--Management) (OP)
15 Sep 08 10:09

I guess looking for help here is a lost cause, especially when I'm the only one writing anything here.

mikrom (Programmer)
19 Sep 08 9:58
> Anyway this gets to line 83 then blows.  Says it can't find or use the agn module in
And where is your agn module?
First search for your file and then add the found path to the Python's sys.path using


sys.path.append('path to my agn-module')
mikrom (Programmer)
19 Sep 08 10:01
sys.path is a list of directories where Python searches for modules.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close