コード例 #1
0
def open_output_text_file():
    """modeled after setting up temporary output file in rebuildSearchFile.py.
    """

    resourcesPath = os.path.join(RepositoryRoot, "Resources.txt")
    try:
        resources = ryw.get_resources(resourcesPath)
        tmpOutDir = ryw.get_resource_str(resources, "tmpout")
        if not tmpOutDir:
            ryw.give_bad_news("SelectTexts.py: failed to get tmpout resource.", logging.error)
            return None
    except:
        ryw.give_bad_news("SelectTexts.py: failed to get resources.", logging.error)
        return None

    dateTimeRand = ryw.date_time_rand()
    textfilePath = os.path.join(tmpOutDir, "Texts2Trans" + dateTimeRand)
    ryw.give_news("PHP file is generated at: ", logging.info)
    ryw.give_news(textfilePath, logging.info)

    try:
        outf = open(textfilePath, "w")
        outf.write("<?\n")
        outf.write("$trans_source = array(")
    except:
        ryw.give_bad_news("SelectTexts.py: unable to open output text file: " + textfilePath, logging.error)
        return None

    return outf
コード例 #2
0
def decide_search_result_dir():
    resources = ryw.get_resources(
        os.path.join(RepositoryRoot,'Resources.txt'))
    if not resources:
        return None

    tmpOutDir = ryw.get_resource_str(resources, 'tmpout')
    if not tmpOutDir:
        ryw.give_bad_news('decide_search_result_dir: no tmpout directory.',
                          logging.error)
        return None

    tmpSearchResultDir = os.path.join(tmpOutDir, 'SearchResults')
    return tmpSearchResultDir
コード例 #3
0
def decide_path():
    resourcesPath = os.path.join(RepositoryRoot, 'Resources.txt')

    try:
        resources = ryw.get_resources(resourcesPath)
        tmpOutDir = ryw.get_resource_str(resources, 'tmpout')
        objectStoreRoot = ryw.get_resource_str(resources, 'objectstore')
        if not tmpOutDir or not objectStoreRoot:
            raise NameError('rebuildSearchFile: failed to get resources.')
        dateTimeRand = ryw.date_time_rand()
        newReverseListsFile = os.path.join(
            tmpOutDir, 'NewReverseLists' + dateTimeRand)
        return (True, newReverseListsFile, objectStoreRoot)
    except:
        ryw.give_bad_news('rebuildSearchFile: failed to get resources.')
        success = (False, None, None)
コード例 #4
0

#ObjectStoreRoot = '\\Postmanet\\repository\\WWW\\ObjectStore'
#OriginalSearchFile = "\\Postmanet\\repository\\SearchFile"



ryw.check_logging(os.path.join(RepositoryRoot, 'WWW', 'logs'), 'upload.log')
logging.debug('rebuildSearchFile: entered...')
ryw_view.print_header_logo()
print '<TITLE>Rebuild Search File</TITLE>'

resourcesPath = os.path.join(RepositoryRoot, 'Resources.txt')

try:
    resources = ryw.get_resources(resourcesPath)
    tmpOutDir = ryw.get_resource_str(resources, 'tmpout')
    ObjectStoreRoot = ryw.get_resource_str(resources, 'objectstore')
    OriginalSearchFile = ryw.get_resource_str(resources, 'searchfile')
    if not tmpOutDir or not ObjectStoreRoot or not OriginalSearchFile:
        raise NameError('rebuildSearchFile: failed to get resources.')
except:
    ryw.give_bad_news('rebuildSearchFile: failed to get resources.',
                      logging.error)
    sys.exit(1)
    


def loadMeta(filename):
    """ loads metadata dictionary from filename"""