Ejemplo n.º 1
0
    def update_project_structure(self):
        old_config = self.buildout._read_installed_part_options()[0]
        # updating old config to project name
        if self.name in old_config:
            old_config = old_config[self.name]

            if 'local-apps' in old_config and\
               old_config['local-apps'] != self.options['local-apps']:
                if os.path.exists(old_config['local-apps']):
                    self.log.info(
                        "GAEBuild: moving local-apps dir from % to %s" %
                        (old_config['local-apps'], self.options['local-apps']))
                    shutil.move(old_config['local-apps'],
                                self.options['local-apps'])

            if 'external-apps' in old_config and\
               old_config['external-apps'] != self.options['external-apps']:
                if os.path.exists(old_config['external-apps']):
                    self.log.info(
                        "GAEBuild: moving external-apps dir from % to %s" %
                        (old_config['external-apps'],
                         self.options['external-apps']))
                    shutil.move(old_config['external-apps'],
                                self.options['external-apps'])

            if 'libs-path' in old_config and\
               old_config['libs-path'] != self.options['libs-path']:
                if os.path.exists(old_config['libs-path']):
                    self.log.info(
                        "GAEBuild: moving libs-path dir from % to %s" %
                        (old_config['libs-path'], self.options['libs-path']))
                    shutil.move(old_config['libs-path'],
                                self.options['libs-path'])

            if 'script-dir' in old_config and\
               old_config['script-dir'] != self.options['script-dir']:
                if os.path.exists(old_config['script-dir']):
                    self.log.info(
                        "GAEBuild: moving script-dir dir from % to %s" %
                        (old_config['script-dir'], self.options['script-dir']))
                    shutil.move(old_config['script-dir'],
                                self.options['script-dir'])

        if not os.path.exists(self.options['local-apps']):
            self.log.info("GAEBuild: creating local-apps dir %s" %
                          (self.options['local-apps']))
            os.makedirs(self.options['local-apps'])

        if not os.path.exists(self.options['external-apps']):
            self.log.info("GAEBuild: creating external-apps dir %s" %
                          (self.options['external-apps']))
            os.makedirs(self.options['external-apps'])

        if not os.path.exists(self.options['libs-path']):
            self.log.info("GAEBuild: creating libs-path dir %s" %
                          (self.options['libs-path']))
            os.makedirs(self.options['libs-path'])

        answer = raw_input("Do you want to install/update apps?(yes/no): ")

        if answer.lower() == 'yes':
            print '\n************** Intalling gae/django apps **************\n'
            apps = self.options.get('apps', '').split()
            if len(apps) == 0:
                self.log.info('No apps to install')
            else:
                install_dir = os.path.abspath(self.options['external-apps'])

                args = [
                    '-U', '-b', self.buildout['buildout']['download-cache'],
                    '-d', install_dir
                ]
                args.extend(apps)

                links = self.options.get('find-links', '').split()

                if len(links) > 0:
                    links.insert(0, '-f')
                    args.extend(links)

                install(args)
            print '\n************** End intalling gae/django apps **************\n'

            print '\n************** Intalling python projects **************\n'

            apps = self.options.get('libs', '').split()
            turboengine = self.options.get('turboengine', '')
            if turboengine != '':
                if turboengine.lower() == 'last':
                    apps.append("turboengine")
                else:
                    apps.append("turboengine==%s" %
                                self.options.get('turboengine'))
                if self.options.get('webservices').lower() == 'true':
                    apps.append("ZSI")
                    apps.append("zope.interface")

            if len(apps) == 0:
                self.log.info('No apps to install')
            else:
                from setuptools.command.easy_install import main
                install_dir = os.path.abspath(self.options['libs-path'])

                if self.options.get('zipped').lower() == 'true':
                    args = ['-U', '-z', '-d', install_dir]
                else:
                    args = ['-U', '-d', install_dir]

                args.extend(['-s', self.options['script-dir']])
                links = self.options.get('find-links', '').split()

                if len(links) > 0:
                    links.insert(0, '-f')
                    args.extend(links)

                args.extend(apps)
                previous_path = os.environ.get('PYTHONPATH', '')
                if previous_path == '':
                    os.environ['PYTHONPATH'] = '%s' % (install_dir)
                else:
                    os.environ['PYTHONPATH'] = '%s:%s' % (install_dir,
                                                          previous_path)

                main(args)  # installing libs

                if previous_path == '':
                    del os.environ['PYTHONPATH']
                else:
                    os.environ['PYTHONPATH'] = previous_path

            print '\n************** End intalling python projects **************\n'
Ejemplo n.º 2
0
    def update_project_structure(self):
        old_config = self.buildout._read_installed_part_options()[0]
        # updating old config to project name
        if self.name in old_config:
            old_config = old_config[self.name]

            if 'local-apps' in old_config and\
               old_config['local-apps'] != self.options['local-apps']:
                if os.path.exists(old_config['local-apps']):
                    self.log.info("GAEBuild: moving local-apps dir from % to %s"%(old_config['local-apps'], self.options['local-apps']))
                    shutil.move(old_config['local-apps'], self.options['local-apps'])

            if 'external-apps' in old_config and\
               old_config['external-apps'] != self.options['external-apps']:
                if os.path.exists(old_config['external-apps']):
                    self.log.info("GAEBuild: moving external-apps dir from % to %s"%(old_config['external-apps'], self.options['external-apps']))
                    shutil.move(old_config['external-apps'], self.options['external-apps'])

            if 'libs-path' in old_config and\
               old_config['libs-path'] != self.options['libs-path']:
                if os.path.exists(old_config['libs-path']):
                    self.log.info("GAEBuild: moving libs-path dir from % to %s"%(old_config['libs-path'], self.options['libs-path']))
                    shutil.move(old_config['libs-path'], self.options['libs-path'])

            if 'script-dir' in old_config and\
               old_config['script-dir'] != self.options['script-dir']:
                if os.path.exists(old_config['script-dir']):
                    self.log.info("GAEBuild: moving script-dir dir from % to %s"%(old_config['script-dir'], self.options['script-dir']))
                    shutil.move(old_config['script-dir'], self.options['script-dir'])

        if not os.path.exists(self.options['local-apps']):
            self.log.info("GAEBuild: creating local-apps dir %s"%(self.options['local-apps']))
            os.makedirs(self.options['local-apps'])

        if not os.path.exists(self.options['external-apps']):
            self.log.info("GAEBuild: creating external-apps dir %s"%(self.options['external-apps']))
            os.makedirs(self.options['external-apps'])

        if not os.path.exists(self.options['libs-path']):
            self.log.info("GAEBuild: creating libs-path dir %s"%(self.options['libs-path']))
            os.makedirs(self.options['libs-path'])

        answer = raw_input("Do you want to install/update apps?(yes/no): ")

        if answer.lower() == 'yes':
            print '\n************** Intalling gae/django apps **************\n'
            apps = self.options.get('apps', '').split()
            if len(apps) == 0:
                self.log.info('No apps to install')
            else:
                install_dir = os.path.abspath(self.options['external-apps'])

                args = ['-U', '-b', self.buildout['buildout']['download-cache'], '-d', install_dir]
                args.extend(apps)

                links = self.options.get('find-links', '').split()

                if len(links)>0:
                    links.insert(0, '-f')
                    args.extend(links)

                install(args)
            print '\n************** End intalling gae/django apps **************\n'

            print '\n************** Intalling python projects **************\n'

            apps = self.options.get('libs', '').split()
            turboengine = self.options.get('turboengine', '')
            if turboengine != '':
                if turboengine.lower() == 'last' :
                    apps.append("turboengine")
                else:
                    apps.append("turboengine==%s"%self.options.get('turboengine'))
                if self.options.get('webservices').lower() == 'true':
                    apps.append("ZSI")
                    apps.append("zope.interface")

            if len(apps) == 0:
                self.log.info('No apps to install')
            else:
                from setuptools.command.easy_install import main
                install_dir = os.path.abspath(self.options['libs-path'])

                if self.options.get('zipped').lower() == 'true':
                    args = ['-U', '-z', '-d', install_dir]
                else:
                    args = ['-U', '-d', install_dir]

                args.extend(['-s', self.options['script-dir']])
                links = self.options.get('find-links', '').split()

                if len(links)>0:
                    links.insert(0, '-f')
                    args.extend(links)

                args.extend(apps)
                previous_path = os.environ.get('PYTHONPATH', '')
                if previous_path == '':
                    os.environ['PYTHONPATH'] = '%s'%(install_dir)
                else:
                    os.environ['PYTHONPATH'] = '%s:%s'%(install_dir, previous_path)

                main(args)# installing libs

                if previous_path == '':
                    del os.environ['PYTHONPATH']
                else:
                    os.environ['PYTHONPATH'] = previous_path

            print '\n************** End intalling python projects **************\n'
Ejemplo n.º 3
0
 def update_project_structure(self):
     old_config = self.buildout._read_installed_part_options()[0]
     # updating old config to project name
     if self.name in old_config:
         old_config = old_config[self.name]
     
         if 'local-apps' in old_config and\
            old_config['local-apps'] != self.options['local-apps']:
             if os.path.exists(old_config['local-apps']):
                 self.log.info("DjBuild: moving local-apps dir from %s to %s"%(old_config['local-apps'], self.options['local-apps']))
                 shutil.move(old_config['local-apps'], self.options['local-apps'])
                 
         if 'external-apps' in old_config and\
            old_config['external-apps'] != self.options['external-apps']:
             if os.path.exists(old_config['external-apps']):
                 self.log.info("DjBuild: moving external-apps dir from %s to %s"%(old_config['external-apps'], self.options['external-apps']))
                 shutil.move(old_config['external-apps'], self.options['external-apps'])
         
     if not os.path.exists(self.options['local-apps']):
         self.log.info("DjBuild: creating local-apps dir %s"%(self.options['local-apps']))
         os.makedirs(self.options['local-apps'])
         
     if not os.path.exists(self.options['external-apps']):
         self.log.info("DjBuild: creating external-apps dir %s"%(self.options['external-apps']))
         os.makedirs(self.options['external-apps'])
         
     answer = raw_input("Do you want to install/update apps?(yes/no): ")
     
     if answer.lower() == 'yes':
         print '\n************** Intalling django apps **************\n'
         apps = self.options.get('apps', '').split()
         if len(apps) == 0:
             self.log.info('No apps to install')
         else:
             install_dir = os.path.abspath(self.options['external-apps'])
             args = ['-U', '-b', self.buildout['buildout']['download-cache'], '-d', install_dir]
             links = self.options.get('find-links', '').split()
             
             if len(links)>0:
                 links.insert(0, '-f')
                 args.extend(links)
                 
             args.extend(apps)
             install(args)
         print '\n************** Intalling django apps **************\n'
         
     print'\n************** Searching for apps config **************\n'
     
     os.environ["DJANGO_SETTINGS_MODULE"] = '%s.project.%s.settings' % (self.options['project'], self.options['settings'])
            
     from django.conf import settings
     
     apps = os.listdir(self.options['external-apps'])
     local_apps = os.listdir(self.options['local-apps'])
     
     # apps into external apps 
     dne = [ x for x in settings.INSTALLED_APPS[:] if x.find('.') == -1 and x not in local_apps] # django and not external
     end = [] # external and not django
     
     del local_apps
     
     for app in apps:
         if app not in settings.INSTALLED_APPS:
             end.append(app)
         elif app in dne:
             dne.remove(app)
     
     # searching for installed apps into djando but not into external-apps directory
    
     if len(end) > 0:
         self.log.warning('These sources apps are installed but not used into django project: \n\t* %s\n'%'\n\t* '.join(end))
             
     # searching for non installed apps into djando but installed into external-apps directory
     if len(dne) > 0:
         self.log.warning('These apps are installed into django but source not installed: \n\t* %s'%'\n\t* '.join(dne))
         
     if len(dne) == 0 and len(end) == 0:
         self.log.info('\nAll is synced')
     
     print '\n************** Searching for apps config **************\n'
     
     del os.environ["DJANGO_SETTINGS_MODULE"]