Пример #1
0
    def load(self, properties):
        alter = File(properties.getPropertyValue("alter.dir"))
        if alter.exists():
            files = Files()
            for version in files.list(alter):
                self.__versions.add(Version(version.getName()))

        create = File(properties.getPropertyValue("create.dir"))
        if create.exists():
            self.__versions.add(
                Version(properties.getPropertyValues("DEFAULT_VERSION")))
Пример #2
0
 def POST(self, hashcode):
   render = self.getRenderer().getRender()   
   db = self.getPersister().getDatabase() 
   
   form = self.getForm()
   
   
   #if not form.validates():
   #    return render.project_edit(project, form)
     
   x = web.input(upload={})
   
   
   folder = File(Path.path('projects',hashcode))
   if not folder.exists():
     os.makedirs(Path.path(folder.getPath(),folder.getName()))    
                   
   fout = open(Path.path('projects',hashcode ,x.upload.filename),'wb') # creates the file where the uploaded file should be stored
   fout.write(x.upload.file.read()) # writes the uploaded file to the newly created file.
   fout.close() # closes the file, u
   
   projectFileModel = ProjectFileModel(db)
   projectFileModel.newProjectFile(hashcode, x.upload.filename)
   
   #projectModel = ProjectModel(db)
   #project = projectModel.getProject(hashcode)
   #projectModel.updateProject(hashcode, form.d.name)
   raise web.seeother('/project_edit/'+hashcode)
Пример #3
0
    def execute(self, commandLine, properties):
        name = commandLine.getOptionValue('-n')
        version = commandLine.getOptionValue('-v')
        current = properties.getPropertyValue('current.dir')

        versions = Versions()
        versionLoader = VersionLoader(versions)
        versionLoader.load(properties)
        versions.sort()
        #print versions.list()
        versionGuesser = VersionGuesser(properties, versions)
        versionFolder = versionGuesser.toFolder(version)

        # create the target folder
        targetPath = Path.path(current, 'target')
        targetFile = File(targetPath)
        if not targetFile.exists():
            os.makedirs(targetPath)

        zipFilename = name + '_' + version + '.zip'
        zipHandle = ZipFile(targetPath + os.sep + zipFilename, 'w')

        files = Files.list(File(versionFolder), True)
        for file in files:
            source = Path.path(file.getPath(), file.getName())
            target = source.replace(current, '')

            zipHandle.write(source, target, zipfile.ZIP_DEFLATED)

        print zipFilename + ' created.'
Пример #4
0
 def getConfigFile(self, properties):
   currentDir = properties.getPropertyValue("current.dir")
   projectFile = properties.getPropertyValue("project.file")
   
   file = File(currentDir + os.sep + projectFile)
   if file.exists():
     return file
   
   nooraDir = properties.getPropertyValue("noora.dir")
   file = File(nooraDir + os.sep + projectFile)
   return file
Пример #5
0
    def execute(self, commandLine, properties):

        project = commandLine.getOptionValue('-pr')
        version = commandLine.getOptionValue('-v')

        configFile = File(
            Path.path(properties.getPropertyValue('current.dir'),
                      properties.getPropertyValue('project.file')))
        if configFile.exists() == False:
            #project = commandLine.getOptionValue('-pr')
            host = commandLine.getOptionValue('-h')
            port = commandLine.getOptionValue('-p')
            database = commandLine.getOptionValue('-d')
            username = commandLine.getOptionValue('-u')
            #password = commandLine.getOptionValue('-p')
            #version = commandLine.getOptionValue('-v')

            # create the project folder
            os.makedirs(project)

            #create project.conf
            templateFolder = Path.path(
                properties.getPropertyValue('plugin.dir'), 'postgresql',
                'generate', 'templates')
            templateFile = File(
                Path.path(properties.getPropertyValue('plugin.dir'),
                          'postgresql', 'generate', 'templates',
                          properties.getPropertyValue('project.file')))
            reader = FileReader(templateFile)
            stream = reader.read()
            stream = stream.replace('{host}', host)
            stream = stream.replace('{port}', port)
            stream = stream.replace('{database}', database)
            stream = stream.replace('{username}', username)
            #stream=stream.replace('{password}',password)
            stream = stream.replace('{version}', version)

            configFile = File(
                Path.path(properties.getPropertyValue('current.dir'), project,
                          properties.getPropertyValue('project.file')))
            writer = FileWriter(configFile)
            writer.write(stream)
            writer.close()

        alterDir = Path.path(properties.getPropertyValue('current.dir'),
                             project, 'alter')
        createDir = Path.path(properties.getPropertyValue('current.dir'),
                              project, 'create')

        # load project.conf
        properties = Properties()
        propertyLoader = PropertyLoader(properties)
        fileReader = FileReader(configFile)
        propertyLoader.load(fileReader)

        properties.setProperty("alter.dir", alterDir)
        properties.setProperty("create.dir", createDir)

        # resolve the version folder
        # create the version folder

        versions = Versions()
        versionLoader = VersionLoader(versions)
        versionLoader.load(properties)
        versions.sort()
        #print versions.list()
        versionGuesser = VersionGuesser(properties, versions)
        nextVersion = versionGuesser.guess(version).toString()
        versionFolder = versionGuesser.toFolder(nextVersion)

        databases = properties.getPropertyValues('DATABASES')
        versionDatabase = properties.getPropertyValues('VERSION_DATABASE')
        defaultVersion = properties.getPropertyValues('DEFAULT_VERSION')
        environments = properties.getPropertyValues('ENVIRONMENTS')
        objects = properties.getPropertyValues('CREATE_OBJECTS')

        # create the version folder
        os.makedirs(versionFolder)

        for database in databases:

            # create the scheme folder
            databaseFolder = versionFolder + os.sep + database
            os.mkdir(databaseFolder)

            # create the dat folder
            datFolder = Path.path(databaseFolder, 'dat')
            os.mkdir(datFolder)

            # create the version script in the dat folder
            if database == versionDatabase:
                versionFile = File(Path.path(datFolder, "version.sql"))
                versionFileWriter = FileWriter(versionFile)

                if nextVersion == defaultVersion:
                    stream = properties.getPropertyValues(
                        'VERSION_INSERT_STATEMENT')
                else:
                    stream = properties.getPropertyValues(
                        'VERSION_UPDATE_STATEMENT')

                stream = stream.replace('<version>', nextVersion)

                versionFileWriter.write(stream)
                versionFileWriter.close()

                #sqlScript=self.getSqlVersionStatement(versions, version)
                #projectHelper.writeFile(datFolder+os.sep+'version.sql', sqlScript)

            # create the environment folders in the dat folder
            for environment in environments:

                os.mkdir(Path.path(datFolder, environment))

                # create the environment script in the dat folder.
                if database == versionDatabase and nextVersion == defaultVersion:
                    environmentFile = File(
                        Path.path(datFolder, environment, 'environment.sql'))
                    environmentFileWriter = FileWriter(environmentFile)
                    stream = properties.getPropertyValues(
                        'ENVIRONMENT_INSERT_STATEMENT')
                    stream = stream.replace('<environment>', environment)

                    environmentFileWriter.write(stream)
                    environmentFileWriter.close()

                    #sqlScript=self.getSqlEnvironmentStatement(environment)
                    #projectHelper.writeFile(datFolder+os.sep+environment+os.sep+'environment.sql', sqlScript)

            # create the ddl folder
            ddlFolder = Path.path(databaseFolder, 'ddl')
            os.mkdir(ddlFolder)

            # create the object folders in the ddl folder
            for object in objects:
                os.mkdir(Path.path(ddlFolder, object))

            # create the template code on create.
            if database == versionDatabase and nextVersion == defaultVersion:
                for object in objects:
                    objectFolder = Path.path(templateFolder, object)
                    objectFile = File(objectFolder)
                    if objectFile.exists():
                        files = Files.list(objectFile)
                        for file in files:
                            fileReader = FileReader(file)
                            stream = fileReader.read()
                            fileReader.close()

                            target = File(
                                Path.path(ddlFolder, object, file.getName()))
                            targetWriter = FileWriter(target)
                            targetWriter.write(stream)
                            targetWriter.close()

        print "version " + nextVersion + " created."
  def execute(self, commandLine, properties):
    
    version = commandLine.getOptionValue('-v')

    configFile = File(Path.path(properties.getPropertyValue('current.dir'),properties.getPropertyValue('project.file')))
    if configFile.exists()==False:      
      client = commandLine.getOptionValue('-c')
      username = commandLine.getOptionValue('-u')
      password = commandLine.getOptionValue('-p')
      workspace = commandLine.getOptionValue('-w')

      #create project.conf
      templateFolder = Path.path(properties.getPropertyValue('plugin.dir'),'tripolis','generate','templates')
      templateFile = File(Path.path(properties.getPropertyValue('plugin.dir'),'tripolis','generate','templates',properties.getPropertyValue('project.file')))
      reader = FileReader(templateFile)
      stream = reader.read()
      stream=stream.replace('{client}',client)
      stream=stream.replace('{username}',username)
      stream=stream.replace('{password}',password)
      stream=stream.replace('{workspace}',workspace)
      
      configFile = File(Path.path(properties.getPropertyValue('current.dir'),properties.getPropertyValue('project.file')))
      writer = FileWriter(configFile)
      writer.write(stream)
      writer.close()

    # create the project folder
    versionDir = Path.path(properties.getPropertyValue('current.dir'), version)
    os.makedirs(versionDir)

    direct_email_type = commandLine.getOptionValue('-d')
    directEmailTypeDir = Path.path(properties.getPropertyValue('current.dir'), version, direct_email_type)
    os.makedirs(directEmailTypeDir)

    # load project.conf
    project_conf = Properties()
    propertyLoader = PropertyLoader(project_conf)
    fileReader = FileReader(configFile)
    propertyLoader.load(fileReader)

    environments = project_conf.getPropertyValues('ENVIRONMENTS')
    for environment in environments:
      os.mkdir(Path.path(properties.getPropertyValue('current.dir'), version, direct_email_type, environment))
    #
    #
    # # load project.conf
    # properties = Properties()
    # propertyLoader = PropertyLoader(properties)
    # fileReader = FileReader(configFile)
    # propertyLoader.load(fileReader)
    #
    # properties.setProperty("alter.dir",alterDir)
    # properties.setProperty("create.dir",createDir)
    #
    #
    # # resolve the version folder
    # # create the version folder
    #
    #
    # versions = Versions()
    # versionLoader = VersionLoader(versions)
    # versionLoader.load(properties)
    # versions.sort()
    # #print versions.list()
    # versionGuesser=VersionGuesser(properties, versions)
    # nextVersion = versionGuesser.guess(version).toString()
    # versionFolder = versionGuesser.toFolder(nextVersion)
    #
    # databases = properties.getPropertyValues('DIRECT_EMAIL_TYPES')   # add to project.cong
    # versionDatabase = properties.getPropertyValues('VERSION_DATABASE')
    # defaultVersion = properties.getPropertyValues('DEFAULT_VERSION')
    # environments = properties.getPropertyValues('ENVIRONMENTS')
    # objects= properties.getPropertyValues('CREATE_OBJECTS')
    #
    # # create the version folder
    # os.makedirs(versionFolder)
    #
    #
    # for database in databases:
    #
    #   # create the scheme folder
    #   databaseFolder=versionFolder+os.sep+database
    #   os.mkdir(databaseFolder)
    #
    #   # create the dat folder
    #   datFolder=Path.path(databaseFolder,'dat')
    #   os.mkdir(datFolder)
    #
    #   # create the version script in the dat folder
    #   if database==versionDatabase:
    #     versionFile = File(Path.path(datFolder,"version.sql"))
    #     versionFileWriter = FileWriter(versionFile)
    #
    #     if nextVersion == defaultVersion:
    #       stream = properties.getPropertyValues('VERSION_INSERT_STATEMENT')
    #     else:
    #       stream = properties.getPropertyValues('VERSION_UPDATE_STATEMENT')
    #
    #     stream=stream.replace('<version>',nextVersion)
    #
    #     versionFileWriter.write(stream)
    #     versionFileWriter.close()
    #
    #     #sqlScript=self.getSqlVersionStatement(versions, version)
    #     #projectHelper.writeFile(datFolder+os.sep+'version.sql', sqlScript)
    #
    #   # create the environment folders in the dat folder
    #   for environment in environments:
    #
    #     os.mkdir(Path.path(datFolder,environment))
    #
    #     # create the environment script in the dat folder.
    #     if database==versionDatabase and nextVersion == defaultVersion:
    #       environmentFile=File(Path.path(datFolder,environment,'environment.sql'))
    #       environmentFileWriter = FileWriter(environmentFile)
    #       stream = properties.getPropertyValues('ENVIRONMENT_INSERT_STATEMENT')
    #       stream=stream.replace('<environment>',environment)
    #
    #       environmentFileWriter.write(stream)
    #       environmentFileWriter.close()
    #
    #       #sqlScript=self.getSqlEnvironmentStatement(environment)
    #       #projectHelper.writeFile(datFolder+os.sep+environment+os.sep+'environment.sql', sqlScript)
    #
    #
    #   # create the ddl folder
    #   ddlFolder=Path.path(databaseFolder,'ddl')
    #   os.mkdir(ddlFolder)
    #
    #   # create the object folders in the ddl folder
    #   for object in objects:
    #     os.mkdir(Path.path(ddlFolder,object))
    #
    #   # create the template code on create.
    #   if database==versionDatabase and nextVersion == defaultVersion:
    #     for object in objects:
    #       objectFolder = Path.path(templateFolder,object)
    #       objectFile = File(objectFolder)
    #       if objectFile.exists():
    #         files = Files.list(objectFile)
    #         for file in files:
    #           fileReader = FileReader(file)
    #           stream = fileReader.read()
    #           fileReader.close()
    #
    #           target = File(Path.path(ddlFolder,object,file.getName()))
    #           targetWriter = FileWriter(target)
    #           targetWriter.write(stream)
    #           targetWriter.close()
    #
    print "version "+version+" created."
    
Пример #7
0
    def testZipPass(self):

        properties = Properties()
        propertyLoader = PropertyLoader(properties)
        file = File("myproject.conf")
        fileReader = FileReader(file)
        propertyLoader.load(fileReader)

        properties.setProperty("current.dir", os.path.abspath('.'))
        properties.setProperty(
            "alter.dir",
            properties.getPropertyValue("current.dir") + os.sep + "alter")
        properties.setProperty(
            "create.dir",
            properties.getPropertyValue("current.dir") + os.sep + "create")

        versions = Versions()
        versionLoader = VersionLoader(versions)
        versionLoader.load(properties)
        versions.sort()
        #print versions.list()
        versionGuesser = VersionGuesser(properties, versions)
        version = versionGuesser.toFolder('1.0.0')

        currentFile = File(os.path.abspath('.'))
        current = Path.path(currentFile.getPath(), currentFile.getName())

        targetPath = Path.path(current, 'target')
        targetFile = File(targetPath)
        if not targetFile.exists():
            os.makedirs(targetPath)

        zipHandle = ZipFile(
            targetPath + os.sep + 'example_' + version + '.zip', 'w')

        excludedFolders = properties.getPropertyValues('EXCLUDED_FOLDERS')

        files = Files.list(currentFile, True)

        filters = Filters()

        excludedFolders = properties.getPropertyValues('EXCLUDED_FOLDERS')
        for excludedFolder in excludedFolders:
            ef = File(excludedFolder)
            ff = FileFolderFilter(ef)
            filters.add(ff)

        for file in files:

            result = False
            for excludedFolder in excludedFolders:
                if excludedFolder in file.getPath() + file.getName():
                    result = True
                    break

            #if filters.accept(file)==False:
            if not result:
                source = Path.path(file.getPath(), file.getName())
                target = source.replace(current, '')
                print file.getPath(), file.getName()

                zipHandle.write(source, target, zipfile.ZIP_DEFLATED)