def remove(cls, name, rc_file='~/.odoorpcrc'): """Remove the session identified by `name` from the `rc_file` file: .. doctest:: :options: +SKIP >>> import odoorpc >>> odoorpc.ODOO.remove('foo') True *Python 2:* :raise: `ValueError` (if the session does not exist) :raise: `IOError` *Python 3:* :raise: `ValueError` (if the session does not exist) :raise: `PermissionError` :raise: `FileNotFoundError` """ data = session.get(name, rc_file) if data.get('type') != cls.__name__: raise error.InternalError( "'{0}' session is not of type '{1}'".format( name, cls.__name__)) return session.remove(name, rc_file)
def load(cls, name, rc_file='~/.odoorpcrc'): """Return a connected :class:`ODOO` session identified by `name`: .. doctest:: :options: +SKIP >>> import odoorpc >>> odoo = odoorpc.ODOO.load('foo') Such sessions are stored with the :func:`save <odoorpc.ODOO.save>` method. *Python 2:* :raise: :class:`odoorpc.error.RPCError` :raise: `urllib2.URLError` (connection error) *Python 3:* :raise: :class:`odoorpc.error.RPCError` :raise: `urllib.error.URLError` (connection error) """ data = session.get(name, rc_file) if data.get('type') != cls.__name__: raise error.InternalError( "'{0}' session is not of type '{1}'".format( name, cls.__name__)) odoo = cls( host=data['host'], protocol=data['protocol'], port=data['port'], timeout=data['timeout'], ) odoo.login(db=data['database'], login=data['user'], password=data['passwd']) return odoo
def load(cls, name, rc_file='~/.odoorpcrc'): """Return a connected :class:`ODOO` session identified by `name`: .. doctest:: :options: +SKIP >>> import odoorpc >>> odoo = odoorpc.ODOO.load('foo') Such sessions are stored with the :func:`save <odoorpc.ODOO.save>` method. *Python 2:* :raise: :class:`odoorpc.error.RPCError` :raise: `urllib2.URLError` (connection error) *Python 3:* :raise: :class:`odoorpc.error.RPCError` :raise: `urllib.error.URLError` (connection error) """ data = session.get(name, rc_file) if data.get('type') != cls.__name__: raise error.InternalError( "'{0}' session is not of type '{1}'".format( name, cls.__name__)) odoo = cls( host=data['host'], protocol=data['protocol'], port=data['port'], timeout=data['timeout'], ) odoo.login( db=data['database'], login=data['user'], password=data['passwd']) return odoo