Exemplo n.º 1
0
def rewrite_meta(metaPath, meta):
    donePath = metaPath.replace('_META', '_DONE')
    mdonPath = metaPath.replace('_META', '_MDON')
    dataPath = metaPath.replace('_META', '_DATA')
    auxiPath = metaPath.replace('_META', '_AUXI')
    paths = (dataPath, metaPath, auxiPath, donePath, mdonPath)
    ryw.db_print3('rewrite_meta: ' + repr(paths), 63)
    ryw.db_print3('rewrite_meta: ' + repr(meta), 62)
    ryw_meta.rewrite_meta(None, None, None, meta, paths)
Exemplo n.º 2
0
def create_registry_entry(dst):
    """moved from install-repository-lai.py
    create repository path in windows registry."""
    ryw.db_print3('ryw_xp:create_registry_entry() entered...', 50)
    try:
        a = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE')
        a = _winreg.CreateKey(a, 'Postmanet')
        a = _winreg.SetValue(a, 'Repository', _winreg.REG_SZ, dst)
    except:
        print 'ERROR>>> Could not set Postmanet\\Repository value in the windows registry.'
Exemplo n.º 3
0
def change_meta(meta, newObjStoreRoot):
    if not meta.has_key('objectstore'):
        ryw.give_bad_news3(
            'meta has no object store: ' +
            meta['id'] + '#' + str(meta['version']))
        ryw.give_bad_news3('    but continuing...')
        oldObjStore = ''
    else:
        oldObjStore = meta['objectstore']
        ryw.db_print3(meta['id'] + '#' + str(meta['version']), 64)
        ryw.db_print3(oldObjStore, 64)

    meta['objectstore'] = newObjStoreRoot
    ryw.give_news3(meta['id'] + '#' + str(meta['version']) + ': ' +
                   oldObjStore + ' -> ' + newObjStoreRoot)
Exemplo n.º 4
0
def get_apache_path():
    """called by install-repository-lai.py"""

    ryw.db_print3('ryw_xp:get_apache_path() entered...', 50)
    
    try:
        a = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE')
        a = _winreg.OpenKey(a, 'Apache Group')
        a = _winreg.OpenKey(a, 'Apache')

        # get latest version
        versions = []
        i = 0
        while True:
            try:
                v = _winreg.EnumKey(a, i)
            except:
                break
            versions.append(v)
            i += 1
        # print 'versions =', versions
        if not versions:
            ##raise 'No apache versions found.'
            return ''

        latestversion = max(versions)
        # print 'latest version =', latestversion

        a = _winreg.OpenKey(a, latestversion)
        i = 0
        val = _winreg.EnumValue(a, i)
        while val[0] != 'ServerRoot':
            i += 1
            val = _winreg.EnumValue(a, i)
        # print 'val =', val
        apachepath = val[1]
        print 'apachepath =', apachepath
        return apachepath
    except:
        print 'ERROR>>> Apache installation not found.'
        return ''
Exemplo n.º 5
0
def main():

    #
    # get all the path names straight.
    #
    try:
        ntfsRoot = sys.argv[1]
    except:
        ryw.give_bad_news3(
            'usage: python reformat_ntfs.py /mnt/usb0/Postmanet ' +
            '[new_object_store_path]')
        sys.exit(-1)

    if len(sys.argv) >= 3:
        newObjStoreRoot = sys.argv[2]
    else:
        newObjStoreRoot = NEW_OBJECT_STORE_ROOT

    ryw.db_print3('newObjectStoreRoot is: ' + newObjStoreRoot, 62)
        
    if (not ntfsRoot) or (not os.path.exists(ntfsRoot)):
        ryw.give_bad_news3("can't find NTFS root: " + ntfsRoot)
        sys.exit(-1)

    ryw.db_print3('NTFS root is at: ' + ntfsRoot, 61)

    repositoryRoot = os.path.join(ntfsRoot, 'repository')
    oldSearchFileName = os.path.join(repositoryRoot, 'SearchFile')
    dateTimeRand = ryw.date_time_rand()
    newSearchFileName = os.path.join(repositoryRoot,
                                     'NewSearchFile' + dateTimeRand)

    objectStoreRoot = os.path.join(repositoryRoot, 'WWW',
                                   'ObjectStore')
    if (not os.path.exists(objectStoreRoot)):
        ryw.give_bad_news3("can't find object store: " + objectStoreRoot)
        sys.exit(-1)
    ryw.db_print3('object store root is at: ' + objectStoreRoot, 61)


    #
    # open the new search file.
    #
    try:
        newSearchFileHandle = open(newSearchFileName, 'ab')
    except:
        ryw.give_bad_news3('failed to open new search file: %s\n' % \
                           (searchfile,))
        sys.exit(-1)
    

    #
    # go through all the individual meta files.
    #
    l = glob.glob(objectStoreRoot + "/?/?/?/?/*_META")
    ryw.give_news3('rewriting meta data files...')
    for filename in l:
        ryw.db_print3('found meta: ' + filename, 61)
        meta = load_meta(filename)
        change_meta(meta, newObjStoreRoot)
        rewrite_meta(filename, meta)
        append_to_new_search_file(newSearchFileHandle, meta)



    #
    # replacing the old search file.
    #

    #ryw.copy_file_carefully('/u/rywang/tmp/x1',
    #                        '/u/rywang/tmp/x2',
    #                        '/u/rywang/tmp',
    #                        None,
    #                        'SearchFile_reformat')

    newSearchFileHandle.close()
    ryw.copy_file_carefully(oldSearchFileName, newSearchFileName,
                            repositoryRoot, None, 'SearchFile_reformat')
    ryw.give_news3('replacing search file: ' + oldSearchFileName +
                   ' <- ' + newSearchFileName)
Exemplo n.º 6
0
import types
import os.path
import logging


#
# import Common
#
cwd = os.getcwd()
common = os.path.join(cwd, 'Common')
if not os.path.exists(common):
    print "can't locate common directory."
    sys.exit(1)
sys.path.append(common)
import ryw
ryw.db_print3('common directory loaded.', 61)
import ryw_meta



def load_meta(filename):
    """ loads metadata dictionary from filename"""
    
    #f = open(filename, "rb")
    #meta = pickle.load(f)
    #f.close()
    meta = ryw.pickle_load_raw_and_text(filename)
    if not sanity_check(meta,filename):
        return None
    else:
        return meta
Exemplo n.º 7
0
def copy_password_file(src, dst):
    """used to be in install-repository-lai.py."""
    shutil.copyfile(os.path.join(src, "pw_linux"), os.path.join(dst, "Passwords"))
    ryw.db_print3("ryw_linux:ryw_password_file() executed.", 50)

    robotPresent = "False"
    if len(sys.argv) == 4:
        if sys.argv[3] == "1":
	    robotPresent = "True"	    

    apachepath = ryw_bizarro.get_apache_path()
    ryw_bizarro.create_registry_entry(dst)


    # TODO: pythonpath unnecessary, but some other script may still
    # want to read it from Resources.txt
    pythonpath = sys.executable

    ryw.db_print3('python path is: ' + pythonpath, 50)
    ryw.db_print3('dst is: ' + dst, 50)

    su.createdirpath(dst)

    #
    # on XP: RepositoryRoot = 'e:\\Postmanet\\repository'
    # on Linux: RepositoryRoot = '/home/rywang/Postmanet/repository'
    #
    repositoryRootString = ryw_bizarro.script_repository_root_string(dst)
    ryw.db_print3('repo root is: ' + repositoryRootString, 50)
    
    #RYW
    #su.copytree(common, os.path.join(dst, 'Common'), isInstall = True)
    su.copyscripttree(common,
                      os.path.join(dst, 'Common'),
Exemplo n.º 9
0
def copy_password_file(src, dst):
    """used to be in install-repository-lai.py."""
    shutil.copyfile(os.path.join(src, 'Passwords'),
                    os.path.join(dst, 'Passwords'))    
    ryw.db_print3('ryw_xp:ryw_password_file() executed.', 50)