def get_zipfile(self, cr, uid, ids, context=None):
     zfilecontent = ''
     if isinstance(ids, (int, long)):
         ids = [ids]
     product = self.browse(cr, uid, ids[0], context)
     zfilename = '%s_%s.zip' % (product.name, uuid.uuid4())
     with cd(path.join(product.repository_id._parent_path, product.repository_id.relpath)):
         dirpath = path.join(os.getcwd(), product.name)
         if path.isdir(dirpath):
             with ZipFile(zfilename, 'w') as zfile:
                 zipdir(path.relpath(dirpath), zfile)
             with open(zfilename, 'rb') as zfile:
                 zfilecontent = zfile.read().encode('base64')
             product.write({'zipfile': zfilecontent, 'zipfilename': '%s.zip' % product.name})
     return {
         'name': _('Download zip'),
         'type': 'ir.actions.act_window',
         'view_type': 'form',
         'view_mode': 'form',
         'res_model': 'product.product',
         'res_id': product.id,
         'view_id': self.pool.get('ir.model.data').get_object_reference(cr, uid, 'smile_module_repository',
                                                                        'view_product_product_form2')[1],
         'target': 'new',
         'context': context,
     }
 def pull(self, cr, uid, ids, context=None):
     if isinstance(ids, (int, long)):
         ids = [ids]
     for rep in self.browse(cr, uid, ids, context):
         if rep.state == 'draft':
             raise orm.except_orm(_('Error'), _('You cannot pull a repository not cloned'))
         with cd(path.join(self._parent_path, rep.relpath)):
             vcs = rep.vcs_id
             IrModuleRepository._call([vcs.cmd, vcs.cmd_pull])
     self.extract_modules(cr, uid, ids, context)
     self.write(cr, uid, ids, {'last_update': time.strftime('%Y-%m-%d %H:%M:%S')}, context)
     self.message_post(cr, uid, ids, body=_("Repository updated"), context=context)
     return True
 def clone(self, cr, uid, ids, context=None):
     if isinstance(ids, (int, long)):
         ids = [ids]
     with cd(self._parent_path):
         for rep in self.browse(cr, uid, ids, context):
             if rep.state != 'draft':
                 raise orm.except_orm(_('Error'), _('You cannot clone a repository already cloned'))
             vcs = rep.vcs_id
             IrModuleRepository._call([vcs.cmd, vcs.cmd_clone, rep.directory, rep.relpath])
     self.extract_modules(cr, uid, ids, context)
     self.write(cr, uid, ids, {'active': True, 'state': 'done', 'last_update': time.strftime('%Y-%m-%d %H:%M:%S')}, context)
     self.message_post(cr, uid, ids, body=_("Repository cloned"), context=context)
     return True
Example #4
0
def install_vim(config_path='/usr/lib/python2.7/config-x86_64-linux-gnu', remove_build_dir=True, tag=None):
    with tempdir(remove_build_dir) as build_dir:
        print('Building Vim at folder {}'.format(build_dir))
        vim_src_dir = os.path.join(build_dir, 'vim_src')
        logging.info('Cloning Vim repo')
        run(['hg', 'clone', 'https://vim.googlecode.com/hg/', vim_src_dir])
        with cd(vim_src_dir):
            if tag:
                run(['hg', 'update', tag]) #-rv7-3-1034, -rv7-4b-022
            run(['./configure', '--enable-multibyte', '--with-tlib=ncurses', '--enable-pythoninterp=yes', 
                '--enable-rubyinterp=yes', '--with-features=huge', '--with-python-config-dir={}'.format(config_path)])
            run(['make', vim_src_dir, '-j', '3'])
            run(['make', vim_src_dir, 'install'])
        logging.info('Vim compiled and installed. Linking to /usr/bin/vim')
        create_symlink('/usr/local/bin/vim', '/usr/bin/vim', backup=False)
Example #5
0
def main():
    parser = argparse.ArgumentParser(description='Mecacell project generator')
    parser.add_argument("name", help='project name')
    parser.add_argument('-c', '--nocmake', help='don\'t generate CmakeList')
    parser.add_argument('-v', '--noviewer',
                        help='no qt viewer, console code only')
    args = parser.parse_args()
    baseDirectory = os.path.dirname(os.path.abspath(__file__)) + \
        '/templates'
    env = Environment(loader=FileSystemLoader(searchpath=baseDirectory))
    viewerEnabled = True
    if args.noviewer is not None:
        viewerEnabled = False

    if (os.path.exists(args.name)):
        msg = t.colors.WARNING + 'path ' + args.name + \
            ' already exists. ' + t.colors.ENDC + 'Overwrite?'
        if not t.queryYN(msg, 'no'):
            sys.exit()
    else:
        os.makedirs(args.name)

    def mkdir(pname):
        if not os.path.exists(pname):
            os.makedirs(pname)

    with t.cd(args.name):
        projName = args.name.split('/')[-1]
        print t.colors.HEADER, 'Generating project', args.name, t.colors.ENDC
        sys.stdout.write(' * creating project architecture')
        if args.nocmake is None:
            mkdir('bin')
            mkdir('build')
        mkdir('src')
        mkdir('src/core')
        t.OK()
        tmplScenario = t.queryYN(
            'Do you want your scenario to be a class template (with cell type as parameter)?', 'no')
        print 'Name of your scenario class? [default = "Scenario"]',
        scName = raw_input()
        if not scName:
            scName = 'Scenario'
        print 'Name of your cell class? [default = "Cell"]',
        cellName = raw_input()
        if not cellName:
            cellName = 'Cell'
        sys.stdout.write(' * generating base source files')
        with open("src/mainconsole.cpp", "wb") as fh:
                fh.write(env.get_template('mainconsole.cpp').render(
                    tmplScenario=tmplScenario, Scenario=scName, Cell=cellName))
        if viewerEnabled:
            with open("src/mainviewer.cpp", "wb") as fh:
                fh.write(env.get_template('mainviewer.cpp').render(
                    tmplScenario=tmplScenario, Scenario=scName, Cell=cellName))
        with open("src/core/" + cellName.lower() + ".h", "wb") as fh:
                fh.write(env.get_template('cell.h').render(Cell=cellName))
        with open("src/core/" + cellName.lower() + ".cpp", "wb") as fh:
                fh.write(env.get_template('cell.cpp').render(Cell=cellName))
        if tmplScenario:
            with open("src/core/" + scName.lower() + ".hpp", "wb") as fh:
                fh.write(env.get_template('scenario.hpp').render(
                    Scenario=scName, Cell=cellName))
        else:
            with open("src/core/" + scName.lower() + ".h", "wb") as fh:
                fh.write(env.get_template('scenario.h').render(
                    Scenario=scName, Cell=cellName))
            with open("src/core/" + scName.lower() + ".cpp", "wb") as fh:
                fh.write(env.get_template('scenario.cpp').render(
                    Scenario=scName, Cell=cellName))
        t.OK()
        if args.nocmake is None:
            sys.stdout.write(' * generating CMakeLists.txt')
            with open("CMakeLists.txt", "wb") as fh:
                fh.write(env.get_template('CMakeLists.txt').render(
                    Project=projName, viewerEnabled=viewerEnabled))
            t.OK()