Skip to content

Instantly share code, notes, and snippets.

@ecarreras
Last active December 28, 2015 10:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecarreras/b5f9dbfeb8a1456f246e to your computer and use it in GitHub Desktop.
Save ecarreras/b5f9dbfeb8a1456f246e to your computer and use it in GitHub Desktop.
Instal·la mòdul remotament
import logging
import os
import click
from erppeek import Client
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('installer')
def setup_peek(**peek_config):
for key, value in os.environ.items():
if key.startswith('PEEK_'):
key = key.split('_')[1].lower()
peek_config[key] = value
logger.info("Using PEEK CONFIG: %s" % peek_config)
return Client(**peek_config)
def install(c, module):
logger.info('Searching for module %s uninstalled' % module)
m = c.model('ir.module.module').search([
('name', '=', module),
('state', '!=', 'installed')
])
if m:
logger.info('Installing module %s...' % module)
c.model('ir.module.module').button_install(m)
wiz_id = c.wizard('module.upgrade')
c.wizard(wiz_id, action='start')
logger.info('Done')
else:
logger.info('Already installed!')
@click.command()
@click.option('-s', '--server', default='http://localhost:8069',
help=u'ERP server address')
@click.option('-u', '--user', default='admin', help='Usuari servidor ERP')
@click.option('-w', '--password', default='admin',
help='Contrasenya usuari ERP')
@click.option('-d', '--db', help='Nom de la base de dades')
@click.option('-i', '--install', help='Install module')
def cli(**kwargs):
module = kwargs.pop('install')
c = setup_peek(**kwargs)
install(c, module)
if __name__ == '__main__':
cli()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment