~domy/corpusfiltergraph/old-main

« back to all changes in this revision

Viewing changes to lib/corpusfg/manager.py

  • Committer: tahoar at precisiontranslationtools
  • Date: 2013-08-23 16:40:46 UTC
  • Revision ID: tahoar@precisiontranslationtools.com-20130823164046-c3ycu8ud3hnjcuof
update constants in getproductdefaults() to find installed setup config file, updated global variable names and changed Windows status logging folder.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
#===============================================================================
7
7
 
8
8
#version:
9
 
#4.6.337 - version update
 
9
#4.6.345 - updated global variable names and changed Windows status logging folder.
10
10
 
11
11
import sys
12
12
import os
20
20
 
21
21
logger = logging.getLogger('.'.join([os.path.splitext(os.path.basename(sys.argv[0]))[0],__name__]))
22
22
 
23
 
homedir = os.path.dirname(os.path.realpath(sys.argv[0]))
24
 
homebase = os.path.basename(homedir)
25
 
prefix = os.path.abspath(os.sep.join([homedir,os.pardir]))
26
 
product = os.path.splitext(os.path.basename(sys.argv[0]))[0]
 
23
__homedir__ = os.path.dirname(os.path.realpath(sys.argv[0]))
 
24
__homebase__ = os.path.basename(__homedir__)
 
25
__prefix__ = os.path.abspath(os.sep.join([__homedir__,os.pardir]))
 
26
__product__ = os.path.splitext(os.path.basename(sys.argv[0]))[0]
27
27
 
28
28
class manager(object):
29
29
        '''manager class processes batches of files through the filtergraph'''
43
43
                'umask': 0,
44
44
                'usemanager': True,
45
45
                'verbose': logging.WARNING,
46
 
                'version': '4.6.344',
 
46
                'version': '4.6.345',
47
47
                'versions': False,
48
48
                }
49
49
        command = 'run'
159
159
                        # create lock file name
160
160
                        self.srcqueue = os.path.abspath(os.path.expanduser(os.sep.join([cfg['filtergraph']['graphs'],cfg['filtergraph']['graphname'],os.extsep.join([cfg['filtergraph']['graphname']])])))
161
161
                        if os.name == 'nt':
162
 
                                if os.path.exists(os.path.join(os.environ['APPDATA'],homebase,''.join([product,'.ini']))) and os.path.join(os.environ['HOMEDRIVE'],os.environ['HOMEPATH']) in homedir:
163
 
                                        pfix = os.path.join(os.environ['APPDATA'],homebase,)
 
162
                                if os.path.exists(os.path.join(os.environ['APPDATA'],__homebase__,''.join([__product__,'.ini']))) \
 
163
                                                and os.path.join(os.environ['HOMEDRIVE'],os.environ['HOMEPATH']) in __homedir__:
 
164
                                        prefix = os.path.join(os.environ['APPDATA'],__homebase__,)
164
165
                                else:
165
 
                                        pfix = os.path.join(os.environ['ALLUSERSPROFILE'],'Application Data',homebase)
166
 
                                lockfile =                              os.sep.join([pfix,'%s.lock'%(cfg['filtergraph']['graphname'])])
167
 
                                self.statusgraph =              os.sep.join([pfix,'%s.%d'%(homebase,os.getpid())])
168
 
                                self.statusplugin =     os.sep.join([pfix,'%s.plugin.%d'%(homebase,os.getpid())])
 
166
                                        prefix = os.path.join(os.environ['ALLUSERSPROFILE'],'Application Data',__homebase__)
 
167
                                lockfile =                              os.sep.join([prefix,'tmp','%s.lock'%(cfg['filtergraph']['graphname'])])
 
168
                                self.statusgraph =              os.sep.join([prefix,'tmp','%s.%d'%(__homebase__,os.getpid())])
 
169
                                self.statusplugin =     os.sep.join([prefix,'tmp','%s.plugin.%d'%(__homebase__,os.getpid())])
169
170
                        elif os.name == 'posix':
170
 
                                lockfile =                              os.sep.join(['','var','tmp',homebase,'%s.lock'%(cfg['filtergraph']['graphname'])])
171
 
                                self.statusgraph =              os.sep.join(['','var','tmp',homebase,'%s.%d'%(homebase,os.getpid())])
172
 
                                self.statusplugin =     os.sep.join(['','var','tmp',homebase,'%s.plugin.%d'%(homebase,os.getpid())])
 
171
                                lockfile =                              os.sep.join(['','var','tmp',__homebase__,'%s.lock'%(cfg['filtergraph']['graphname'])])
 
172
                                self.statusgraph =              os.sep.join(['','var','tmp',__homebase__,'%s.%d'%(__homebase__,os.getpid())])
 
173
                                self.statusplugin =     os.sep.join(['','var','tmp',__homebase__,'%s.plugin.%d'%(__homebase__,os.getpid())])
173
174
 
174
175
                        if cfg['cleanup']:
175
176
                                if os.path.exists(lockfile): os.unlink(lockfile)