Пример #1
0
def SetReleaseInformation(notesSession, sTemplateCompletePath, sName, sVersion,
                          sBuildNumber, sBuildDate):
    try:

        myLog("Adding release information to template %s (%s.%s - %s)" %
              (sTemplateCompletePath, sVersion, sBuildNumber, sBuildDate))
        cnvDate = datetime.strptime(sBuildDate.strip(), "%Y%m%d")
        TheDate = notesSession.CreateDateTime(cnvDate.strftime("%m-%d-%Y"))

        targetDb = notesSession.GetDatabase("", sTemplateCompletePath)
        targetView = targetDb.GetView("$Design")
        if targetView is None:
            print "$Design not found"
        else:
            targetDesignDoc = targetView.GetDocumentByKey(
                "$TemplateBuild", True)
            targetDesignDoc.ReplaceItemValue(
                "$TemplateBuild", (sVersion + "." + sBuildNumber).split())
            targetDesignDoc.ReplaceItemValue("$move4ideasSoftware", sName)
            targetDesignDoc.ReplaceItemValue("$move4ideasBuild", sBuildNumber)
            targetDesignDoc.ReplaceItemValue("$move4ideasVersion", sVersion)
            targetDesignDoc.ReplaceItemValue("$TemplateBuildDate",
                                             TheDate.DateOnly)

            targetDesignDoc.Save(0, 0)

    except pythoncom.com_error as error:
        print(error)
        print(vars(error))
        print(error.args)
Пример #2
0
def ods2nxf(sDesigner, sFrom, sTo):
    # Make tmp command file
    bResult = True;
    prjFile = os.path.join(sFrom, ".project")
    path2Result, resultName= os.path.split(sTo)
    path2designer, desName = os.path.split(sDesigner)
    
    with tempfile.NamedTemporaryFile(delete = False) as commandFile:
#         commandFile.write('config,true,true\n')   # Stop on error / Exit on error
#         commandFile.write('importandbuild,%s,%s\n' % (prjFile,sTo) )
#         commandFile.write('clean\n')
#         commandFile.write('exit\n')
#         commandFile.flush()
# 
#         sInvoke = "%s -RPARAMS -vmargs  -Dcom.ibm.designer.cmd.file=%s" % (sDesigner,commandFile.name)
        sInvoke = "%s -RPARAMS -vmargs  -Dcom.ibm.designer.cmd=true,true,%s,importandbuild,%s,%s" % (sDesigner,resultName,prjFile,resultName)
        myLog("Invoking %s" % sInvoke)
        subprocess.call(sInvoke) 
        while isDesignerRunning():
            time.sleep(1)
        myLog("End of designer build process")
        # Check result
        for line in open("HEADLESS0.log"):
            if "job error" in line:
                print line
                bResult = False;
        
        if (bResult == True):
            sTempResult ="%s/Data/%s" % (path2designer,resultName) 
            os.rename(sTempResult, sTo)
        else:
            os.remove(sTempResult)
        return bResult 
Пример #3
0
def SetReleaseInformation(notesSession, sTemplateCompletePath, sName, sVersion, sBuildNumber, sBuildDate):
    try:    
    
        myLog("Adding release information to template %s (%s.%s - %s)" % (sTemplateCompletePath, sVersion, sBuildNumber, sBuildDate))
        cnvDate = datetime.strptime(sBuildDate.strip(),"%Y%m%d")   
        TheDate = notesSession.CreateDateTime(cnvDate.strftime("%m-%d-%Y"))

        targetDb = notesSession.GetDatabase("", sTemplateCompletePath)
        targetView = targetDb.GetView("$Design")
        if targetView is None:
            print "$Design not found"
        else:
            targetDesignDoc = targetView.GetDocumentByKey("$TemplateBuild",True)
            targetDesignDoc.ReplaceItemValue("$TemplateBuild",(sVersion + "." + sBuildNumber).split())
            targetDesignDoc.ReplaceItemValue("$move4ideasSoftware",sName)
            targetDesignDoc.ReplaceItemValue("$move4ideasBuild",sBuildNumber)
            targetDesignDoc.ReplaceItemValue("$move4ideasVersion",sVersion)
            targetDesignDoc.ReplaceItemValue("$TemplateBuildDate",TheDate.DateOnly)
        
            targetDesignDoc.Save(0,0)

    except pythoncom.com_error as error:
        print (error)
        print (vars(error))
        print (error.args)
Пример #4
0
def TagDirectory(notesSession, sDirectory, sName,sVersion,sBuild,sDate):

    myLog("Tagging %s directory" % sDirectory)
    
    # Get NTF/NSF list from directory
    included_ext = ['ntf'] ;
    fileLst = [ fn for fn in listdir(sDirectory) if any([fn.endswith(ext) for ext in included_ext])];
    
    for notesFile in fileLst:
        SetReleaseInformation(notesSession, sDirectory+"\\"+notesFile, sName, sVersion, sBuild, sDate)
Пример #5
0
def main(argv=None): # IGNORE:C0111
    global  notesapi

    if argv is None:
        argv = sys.argv
    else:
        sys.argv.extend(argv)

    program_name = os.path.basename(sys.argv[0])

    try:
        # Setup argument parser
        parser = ArgumentParser(description="", formatter_class=RawDescriptionHelpFormatter)
        parser.add_argument("-n", "--name",    dest="name", action="store", help="NSF/NTF to clean up]")
        parser.add_argument("-f", "--fulldir",    dest="directory", action="store", help="path to compile]")
        parser.add_argument("-u", "--user",    dest="user",     action="store", help="user id short filename (relative to Notes/Data)")
        parser.add_argument("-v", "--verbose", dest="verbose", action="count", help="set verbosity level [default: %(default)s]")

        # Process arguments
        args = parser.parse_args()

        SetVerbosity(args.verbose)
        myLog("Args are %s " % args)

        if (args.user is not None):
            SwitchUser(args.user)

        notesSession = SetupNotesClient(args.verbose)
        notesapi.NotesInitExtended(sys.argv)      

        if not (args.name is None):
            result = CleanDatabase(notesSession, args.name)
        elif (not args.directory is None):
            result = CleanDirectory(notesSession, args.directory.strip())
        else:
            print "No input specified"

        notesapi.NotesTerm
        myLog("Returning %d " % result)
        return 0 if (result == True) else 1

    except KeyboardInterrupt:
        ### handle keyboard interrupt ###
        return 0
    except Exception, e:
        print 'Error on line {}\n'.format(sys.exc_info()[-1].tb_lineno)
        print ("Error: %s.\n" % str(e))
        if DEBUG or TESTRUN:
            raise(e)
        indent = len(program_name) * " "
        sys.stderr.write(program_name + ": " + repr(e) + "\n")
        sys.stderr.write(indent + "  for help use --help")
        notesapi.NotesTerm
        return 2
Пример #6
0
def main(argv=None): # IGNORE:C0111
    if argv is None:
        argv = sys.argv
    else:
        sys.argv.extend(argv)

    program_name = os.path.basename(sys.argv[0])

    try:
        # Setup argument parser
        parser = ArgumentParser(description="", formatter_class=RawDescriptionHelpFormatter)
        parser.add_argument("-f", "--from",    dest="src",      action="store", help="From source On disk structure (full path)")
        parser.add_argument("-t", "--to",      dest="dst",      action="store", help="To NSF/NTF result (full path)")
        parser.add_argument("-u", "--user",    dest="user",     action="store", help="user id short filename (relative to Notes/Data)")
        parser.add_argument("-v", "--verbose", dest="verbose",  action="count", help="set verbosity level [default: %(default)s]")

        # Process arguments
        args = parser.parse_args()

        SetVerbosity(args.verbose)
        myLog("Args are %s " % args)

        if isDesignerRunning():
            print("Cannot run while notes is already running")
            return 2
        
        if (args.user is not None):
            SwitchUser(args.user)
        
        designer = FindDesigner()
        if (designer is not None):
            path2designer, desName = os.path.split(designer)
            EnableHeadlessDesigner(path2designer)
            result = ods2nxf(designer, args.src, args.dst)
        else:
            result = False;
                
        return 0 if (result == True) else 1

    except KeyboardInterrupt:
        ### handle keyboard interrupt ###
        return 0
    except Exception, e:
		print 'Error on line {}\n'.format(sys.exc_info()[-1].tb_lineno)
		print ("Error: %s.\n" % str(e))
		if DEBUG or TESTRUN:
			raise(e)
		indent = len(program_name) * " "
		sys.stderr.write(program_name + ": " + repr(e) + "\n")
		sys.stderr.write(indent + "  for help use --help")
		notesapi.NotesTerm
		return 2
Пример #7
0
def CompileDirectory(notesSession, sDirectory):
    myLog("Compiling %s directory" % sDirectory)
    
    # Get NTF/NSF list from directory
    included_ext = ['ntf'] ;
    fileLst = [ fn for fn in listdir(sDirectory) if any([fn.endswith(ext) for ext in included_ext])];
    
    for notesFile in fileLst:
        result = CompileDatabase(notesSession, sDirectory+"\\"+notesFile)
        if not result: 
			break;
			
    return result
Пример #8
0
def TagDirectory(notesSession, sDirectory, sName, sVersion, sBuild, sDate):

    myLog("Tagging %s directory" % sDirectory)

    # Get NTF/NSF list from directory
    included_ext = ['ntf']
    fileLst = [
        fn for fn in listdir(sDirectory)
        if any([fn.endswith(ext) for ext in included_ext])
    ]

    for notesFile in fileLst:
        SetReleaseInformation(notesSession, sDirectory + "\\" + notesFile,
                              sName, sVersion, sBuild, sDate)
Пример #9
0
def CleanDirectory(notesSession, sDirectory):
    myLog( "Cleaning %s directory" % sDirectory)
    
    # Get NTF/NSF list from directory
    included_ext = ['ntf'] ;
    fileLst = [ fn for fn in listdir(sDirectory) if any([fn.endswith(ext) for ext in included_ext])];
    
    for notesFile in fileLst:
        result = CleanDatabase(notesSession, sDirectory+"\\"+notesFile)
        if not result:
            print result
            break;

    return result
Пример #10
0
def CleanDatabase(notesSession, sDatabaseName):
    global  notesapi
    result = False
    
    # Get Database as a COM object
    try:
        comDB = notesSession.GetDatabase("", sDatabaseName)
        myLog("Cleaning %s (%s)" % (sDatabaseName, comDB.Title.encode('ascii', 'ignore')))
        apiDB = notesapi.NSFDbOpen(sDatabaseName)
        nc = comDB.CreateNoteCollection(True)
        result = CleanCollection(apiDB, comDB, nc, "Cleaning design elements")
        notesapi.NSFDbClose(apiDB)
        return result
        
    except Exception,err :
        print 'Error on line {}'.format(sys.exc_info()[-1].tb_lineno)
        print ("Error: %s.\n" % str(err))
Пример #11
0
def main(argv=None): # IGNORE:C0111
    if argv is None:
        argv = sys.argv
    else:
        sys.argv.extend(argv)

    
    program_name = os.path.basename(sys.argv[0])

    try:
        # Setup argument parser
        parser = ArgumentParser(description="", formatter_class=RawDescriptionHelpFormatter)
        parser.add_argument("-n", "--name",    dest="name", action="store", help="application name]")
        parser.add_argument("-v", "--verbose", dest="verbose", action="count", help="set verbosity level [default: %(default)s]")
        parser.add_argument("-b", "--build",   dest="build", action="store", help="build number")
        parser.add_argument("-r", "--release", dest="version", help="version string (1.2.1)")
        parser.add_argument("-s", "--source", dest="source",action="store",help="Source of code")
        parser.add_argument("-u", "--user",    dest="user",     action="store", help="user id short filename (relative to Notes/Data)")
        parser.add_argument("-d", "--dir", dest="dir",action="store",help="directory where to apply modifications")

        # Process arguments
        args = parser.parse_args()

        SetVerbosity(args.verbose)
        
        if (args.user is not None):
            SwitchUser(args.user)
        
        notesSession = SetupNotesClient(args.verbose)

        result = UpgradeDesign(notesSession, args.dir,args.source)
        myLog("Done - result " +str( result))
        
        return 0 if (result == True) else 1

    except KeyboardInterrupt:
        ### handle keyboard interrupt ###
        return 0
    except Exception, e:
        if DEBUG or TESTRUN:
            raise(e)
        indent = len(program_name) * " "
        sys.stderr.write(program_name + ": " + repr(e) + "\n")
        sys.stderr.write(indent + "  for help use --help")
        return 2
Пример #12
0
def RecompileLS(apiDb, comDb, noteID):
    global lastError

    try:
        if (apiDb is None):
            lastError = "Database is not open"
            return False

        comNotesDocument = comDb.GetDocumentByID(noteID)

        hNote = notesapi.NSFNoteOpen(apiDb, noteID, 0)

        #     notesClass = notesapi.NSFNoteGetClass(hNote)
        #     print notesClass
        #** first, we compile the note
        result = notesapi.NSFNoteLSCompile(apiDb, hNote, 0)
        if (result <> 0):
            if (result <> 0x0222):
                lastError = "Cannot compile LotusScript"
                return False
            else:
                myLog("Compilation error  %04X" % result)

        #** then we sign it
        result = notesapi.NSFNoteSign(hNote)
        if (result <> 0):
            lastError = "Cannot sign"
            return False

        #** then we save it
        result = notesapi.NSFNoteUpdate(hNote, 0)
        if (result <> 0):
            lastError = "Cannot save"
            return False
        notesapi.NSFNoteClose(hNote)

        lastError = ""
        return True

    except Exception, err:
        print 'Error on line {}'.format(sys.exc_info()[-1].tb_lineno)
        print("Error: %s.\n" % str(err))
        return False
Пример #13
0
def RecompileLS(apiDb, comDb, noteID):
    global lastError

    try:
        if (apiDb is None):
            lastError = "Database is not open"
            return False
    
        comNotesDocument = comDb.GetDocumentByID(noteID)
    
        hNote = notesapi.NSFNoteOpen(apiDb,noteID,0)
        
    #     notesClass = notesapi.NSFNoteGetClass(hNote)
    #     print notesClass
        #** first, we compile the note
        result = notesapi.NSFNoteLSCompile(apiDb, hNote, 0)
        if (result <> 0):
            if (result <> 0x0222):
                lastError = "Cannot compile LotusScript"
                return False
            else:
                myLog("Compilation error  %04X" % result)
         
        #** then we sign it
        result = notesapi.NSFNoteSign(hNote)
        if (result <> 0):
            lastError="Cannot sign"
            return False
         
        #** then we save it
        result = notesapi.NSFNoteUpdate(hNote, 0)
        if (result <> 0):
            lastError="Cannot save"
            return False
        notesapi.NSFNoteClose(hNote)
        
        lastError = ""
        return True

    except Exception,err :
        print 'Error on line {}'.format(sys.exc_info()[-1].tb_lineno)
        print ("Error: %s.\n" % str(err))
        return False
Пример #14
0
def CompileDatabase(notesSession, sDatabaseName):
    global notesapi
    result = False
    try:

        # Get Database as a COM object
        comDB = notesSession.GetDatabase("", sDatabaseName)
        myLog("Compiling %s (%s)" %
              (sDatabaseName, comDB.Title.encode('ascii', 'ignore')))
        apiDB = notesapi.NSFDbOpen(sDatabaseName)
        #** compile the script libraries first (note that this will NOT build a
        #** dependency tree -- rather, we'll try to brute-force around the
        #** dependencies by recompiling until either (A) there are no errors,
        #** or (B) the number of errors we get is the same as we got last time)

        nc = comDB.CreateNoteCollection(False)
        nc.SelectScriptLibraries = True
        if (CompileCollection(apiDB, comDB, nc, "Script libraries")):
            #** then compile everything else
            nc = comDB.CreateNoteCollection(True)
            nc.SelectScriptLibraries = False
            nc.SelectACL = False
            nc.SelectDataConnections = False
            nc.SelectHelpAbout = False
            nc.SelectHelpIndex = False
            nc.SelectHelpUsing = False
            nc.SelectIcon = False
            nc.SelectImageResources = False
            nc.SelectJavaResources = False
            nc.SelectProfiles = False
            nc.SelectScriptLibraries = False
            nc.SelectStyleSheetResources = False
            if CompileCollection(apiDB, comDB, nc, "The rest"):
                result = True

        notesapi.NSFDbClose(apiDB)
        return result
    except Exception, err:
        print 'Error on line {}'.format(sys.exc_info()[-1].tb_lineno)
        print("Error: %s.\n" % str(err))
        return False
Пример #15
0
def CleanCollection(apiDB, comDB, theCollection, title):
    theCollection.BuildCollection()
    myLog("Cleaning %d Docs (%s)" % (theCollection.Count, title))
    cleanCount = 0

    noteID = theCollection.GetFirstNoteId()
    comNotesDocument = comDB.GetDocumentByID(noteID)
    while not (comNotesDocument is None):
        #get it    
        comNotesDocument.RemoveItem("$Updatedby")
        
        comNotesDocument.Save(True,False,False)
        cleanCount = cleanCount +1
        
        noteID = theCollection.GetNextNoteId(noteID)
        if (noteID <> ""):
            comNotesDocument = comDB.GetDocumentByID(noteID)
        else:
            comNotesDocument = None
    
    return True   
Пример #16
0
def CompileDatabase(notesSession, sDatabaseName):
    global  notesapi
    result = False
    try:    
        
        # Get Database as a COM object
        comDB = notesSession.GetDatabase("", sDatabaseName)
        myLog("Compiling %s (%s)" % (sDatabaseName, comDB.Title.encode('ascii', 'ignore')))
        apiDB = notesapi.NSFDbOpen(sDatabaseName)
        #** compile the script libraries first (note that this will NOT build a
        #** dependency tree -- rather, we'll try to brute-force around the 
        #** dependencies by recompiling until either (A) there are no errors,
        #** or (B) the number of errors we get is the same as we got last time)

        nc = comDB.CreateNoteCollection(False)
        nc.SelectScriptLibraries = True
        if (CompileCollection(apiDB,comDB, nc,"Script libraries")):
            #** then compile everything else
            nc = comDB.CreateNoteCollection(True)
            nc.SelectScriptLibraries = False
            nc.SelectACL = False
            nc.SelectDataConnections= False
            nc.SelectHelpAbout= False
            nc.SelectHelpIndex= False
            nc.SelectHelpUsing= False
            nc.SelectIcon= False
            nc.SelectImageResources= False
            nc.SelectJavaResources= False
            nc.SelectProfiles= False
            nc.SelectScriptLibraries= False
            nc.SelectStyleSheetResources= False
            if CompileCollection(apiDB, comDB,nc,"The rest"):
                result = True
        
        notesapi.NSFDbClose(apiDB)
        return result
    except Exception,err :
        print 'Error on line {}'.format(sys.exc_info()[-1].tb_lineno)
        print ("Error: %s.\n" % str(err))
        return False
Пример #17
0
def SignCollection(apiDB, comDB, theCollection, title):
    theCollection.BuildCollection()
    myLog("Signing %d Docs (%s)" % (theCollection.Count, title))
    cleanCount = 0

    noteID = theCollection.GetFirstNoteId()
    comNotesDocument = comDB.GetDocumentByID(noteID)
    while not (comNotesDocument is None):
        #** a little trick to avoid this message on recompiled forms:
        #** This document has been altered since the last time it was signed! Intentional tampering may have occurred.
        comNotesDocument.Sign()
        comNotesDocument.Save(True, False)
        
        signCount = cleanCount +1
        
        noteID = theCollection.GetNextNoteId(noteID)
        if (noteID <> ""):
            comNotesDocument = comDB.GetDocumentByID(noteID)
        else:
            comNotesDocument = None

    return True   
Пример #18
0
def CompileCollection(apiDB,comDB, theCollection,title):
    
    theCollection.BuildCollection()
    myLog("Compiling %d items (%s)" % (theCollection.Count, title))
    compileCount = 0

    noteID = theCollection.GetFirstNoteId()
    while (noteID <> ""):
        if RecompileLS(apiDB,comDB,noteID):
            myLog("  - " + GetTitle(comDB.GetDocumentByID(noteID)))
            compileCount = compileCount +1
        else:
            print "Error (%s) compiling %s " % (lastError,GetTitle(comDB.GetDocumentByID(noteID)))
            break
         
        noteID = theCollection.GetNextNoteId(noteID)

    myLog("Compiled %d items\n" % compileCount)
    return (theCollection.Count == compileCount)
Пример #19
0
def CompileCollection(apiDB, comDB, theCollection, title):

    theCollection.BuildCollection()
    myLog("Compiling %d items (%s)" % (theCollection.Count, title))
    compileCount = 0

    noteID = theCollection.GetFirstNoteId()
    while (noteID <> ""):
        if RecompileLS(apiDB, comDB, noteID):
            myLog("  - " + GetTitle(comDB.GetDocumentByID(noteID)))
            compileCount = compileCount + 1
        else:
            print "Error (%s) compiling %s " % (
                lastError, GetTitle(comDB.GetDocumentByID(noteID)))
            break

        noteID = theCollection.GetNextNoteId(noteID)

    myLog("Compiled %d items\n" % compileCount)
    return (theCollection.Count == compileCount)
Пример #20
0
def UpgradeDesign(notesSession, sTargetRootDir, sSourceCode):
    try:

        myLog("Upgrade design %s <= %s " % (sTargetRootDir, sSourceCode))

        sourceDb = notesSession.GetDatabase("", sSourceCode)
        srcDesignView = sourceDb.GetView("$Design")
        # Get projets
        projects = sourceDb.GetView("Projects")
        if not projects:
            raise Exception('No projects found')

        # build all projects
        #for myProject in iterateDocuments(projects):
        myProject = projects.GetFirstDocument()
        projectCount = 1
        while myProject:
            myLog("Project " + str(projectCount))
            DesignList = myProject.GetItemValue("ProjectDesigns")
            DatabasesList = myProject.GetItemValue("ProjectDatabases")
            myProject = projects.GetNextDocument(myProject)
            projectCount = projectCount + 1
            # iterate through notes databases
            for DbFilename in DatabasesList:
                # first open the db
                targetDb = notesSession.GetDatabase(
                    "", sTargetRootDir + "\\" + DbFilename)

                if not (targetDb.IsOpen):
                    myLog("Cannot open local database: %s\\%s" %
                          (sTargetRootDir, DbFilename))
                    return False
                else:
                    myLog("Opened: %s\\%s" % (sTargetRootDir, DbFilename))
                    targetView = targetDb.GetView("$Design")
                    if targetView is None:
                        myLog("Cannot find $Design in %s" % DbFilename)
                        ForceCopy = True
                    else:
                        targetView.Refresh
                        ForceCopy = False

                        # iterate through design documents
                    for designElt in DesignList:
                        myLog("Applying : %s" % designElt)
                        curDesignDoc = srcDesignView.GetDocumentByKey(
                            designElt, True)
                        if not (curDesignDoc is None):
                            if not ForceCopy:
                                # try to find targetDesignDoc in targetView
                                key = curDesignDoc.GetItemValue("$Title")
                                targetDesignDoc = targetView.GetDocumentByKey(
                                    key, True)
                                if not (targetDesignDoc is None):
                                    targetDesignDoc.Remove(True)

                            myLog("Design copy of %s" % designElt)
                            curDesignDoc.CopyToDatabase(targetDb)
                            # We need to copy it to the destination database
                        else:
                            myLog("Source design element %s not found" %
                                  designElt)
                            return False

        return True

    except Exception, err:
        print 'Error on line {}'.format(sys.exc_info()[-1].tb_lineno)
        print("Error: %s.\n" % str(err))
Пример #21
0
def SwitchUser(sIdFile):
    path2notes, desName = os.path.split(FindNotes())
    notesIniFile = os.path.join(path2notes, "notes.ini")
    myLog("Switching to ID file %s" % sIdFile)
    setIniKey(notesIniFile, "Notes", "KeyfileName", sIdFile)
Пример #22
0
def SwitchUser(sIdFile):
    path2notes, desName = os.path.split(FindNotes())
    notesIniFile= os.path.join(path2notes, "notes.ini")
    myLog("Switching to ID file %s" % sIdFile)
    setIniKey(notesIniFile, "Notes","KeyfileName",sIdFile)
Пример #23
0
def UpgradeDesign(notesSession, sTargetRootDir, sSourceCode):
    try:    
    
        myLog("Upgrade design %s <= %s " % (sTargetRootDir, sSourceCode))
        
        sourceDb = notesSession.GetDatabase("", sSourceCode)
        srcDesignView = sourceDb.GetView("$Design")
        # Get projets 
        projects = sourceDb.GetView("Projects")
        if not projects:
            raise Exception('No projects found')
    
        # build all projects
        #for myProject in iterateDocuments(projects):
        myProject  = projects.GetFirstDocument()
        projectCount = 1
        while myProject:
            myLog("Project " + str(projectCount))
            DesignList = myProject.GetItemValue("ProjectDesigns")
            DatabasesList = myProject.GetItemValue("ProjectDatabases")
            myProject = projects.GetNextDocument(myProject)
            projectCount = projectCount + 1
            # iterate through notes databases
            for DbFilename in DatabasesList:
                # first open the db
                targetDb = notesSession.GetDatabase("",sTargetRootDir+"\\"+DbFilename)

                if not(targetDb.IsOpen):
                    myLog("Cannot open local database: %s\\%s" % (sTargetRootDir, DbFilename))
                    return False
                else:
                    myLog("Opened: %s\\%s" % (sTargetRootDir,DbFilename))
                    targetView = targetDb.GetView("$Design")
                    if targetView is None:
                        myLog("Cannot find $Design in %s" % DbFilename)
                        ForceCopy = True
                    else:
                        targetView.Refresh
                        ForceCopy = False
                    
                        # iterate through design documents
                    for designElt in DesignList:
                        myLog("Applying : %s" % designElt)
                        curDesignDoc = srcDesignView.GetDocumentByKey(designElt,True)
                        if not (curDesignDoc is None):
                            if not ForceCopy:
                                # try to find targetDesignDoc in targetView
                                key = curDesignDoc.GetItemValue("$Title")
                                targetDesignDoc = targetView.GetDocumentByKey(key,True)
                                if not (targetDesignDoc is None):
                                    targetDesignDoc.Remove(True)
                                
                            myLog("Design copy of %s" % designElt)
                            curDesignDoc.CopyToDatabase(targetDb)
                            # We need to copy it to the destination database
                        else:
                            myLog("Source design element %s not found" % designElt)
                            return False

        return True
    
    except Exception,err :
        print 'Error on line {}'.format(sys.exc_info()[-1].tb_lineno)
        print ("Error: %s.\n" % str(err))
Пример #24
0
def main(argv=None):  # IGNORE:C0111
    if argv is None:
        argv = sys.argv
    else:
        sys.argv.extend(argv)

    program_name = os.path.basename(sys.argv[0])

    try:
        # Setup argument parser
        parser = ArgumentParser(description="",
                                formatter_class=RawDescriptionHelpFormatter)
        parser.add_argument("-n",
                            "--name",
                            dest="name",
                            action="store",
                            help="application name]")
        parser.add_argument("-v",
                            "--verbose",
                            dest="verbose",
                            action="count",
                            help="set verbosity level [default: %(default)s]")
        parser.add_argument("-b",
                            "--build",
                            dest="build",
                            action="store",
                            help="build number")
        parser.add_argument("-r",
                            "--release",
                            dest="version",
                            help="version string (1.2.1)")
        parser.add_argument("-s",
                            "--source",
                            dest="source",
                            action="store",
                            help="Source of code")
        parser.add_argument(
            "-u",
            "--user",
            dest="user",
            action="store",
            help="user id short filename (relative to Notes/Data)")
        parser.add_argument("-d",
                            "--dir",
                            dest="dir",
                            action="store",
                            help="directory where to apply modifications")

        # Process arguments
        args = parser.parse_args()

        SetVerbosity(args.verbose)

        if (args.user is not None):
            SwitchUser(args.user)

        notesSession = SetupNotesClient(args.verbose)

        result = UpgradeDesign(notesSession, args.dir, args.source)
        myLog("Done - result " + str(result))

        return 0 if (result == True) else 1

    except KeyboardInterrupt:
        ### handle keyboard interrupt ###
        return 0
    except Exception, e:
        if DEBUG or TESTRUN:
            raise (e)
        indent = len(program_name) * " "
        sys.stderr.write(program_name + ": " + repr(e) + "\n")
        sys.stderr.write(indent + "  for help use --help")
        return 2