Esempio n. 1
0
    def __init__(self, username, password, httpsession):
        """Initialize the data object."""
        from pyebox import EboxClient

        self.client = EboxClient(username, password, REQUESTS_TIMEOUT,
                                 httpsession)
        self.data = {}
Esempio n. 2
0
class EBoxData(object):
    """Get data from Ebox."""
    def __init__(self, username, password):
        """Initialize the data object."""
        from pyebox import EboxClient
        self.client = EboxClient(username, password, REQUESTS_TIMEOUT)
        self.data = {}

    def update(self):
        """Get the latest data from Ebox."""
        from pyebox.client import PyEboxError
        try:
            self.client.fetch_data()
        except PyEboxError as exp:
            _LOGGER.error("Error on receive last EBox data: %s", exp)
            return
        self.data = self.client.get_data()
Esempio n. 3
0
class EBoxData(object):
    """Get data from Ebox."""

    def __init__(self, username, password):
        """Initialize the data object."""
        from pyebox import EboxClient
        self.client = EboxClient(username, password, REQUESTS_TIMEOUT)
        self.data = {}

    def update(self):
        """Get the latest data from Ebox."""
        from pyebox.client import PyEboxError
        try:
            self.client.fetch_data()
        except PyEboxError as exp:
            _LOGGER.error("Error on receive last EBox data: %s", exp)
            return
        self.data = self.client.get_data()
Esempio n. 4
0
class EBoxData:
    """Get data from Ebox."""
    def __init__(self, username, password, httpsession):
        """Initialize the data object."""
        self.client = EboxClient(username, password, REQUESTS_TIMEOUT,
                                 httpsession)
        self.data = {}

    @Throttle(MIN_TIME_BETWEEN_UPDATES)
    async def async_update(self):
        """Get the latest data from Ebox."""
        try:
            await self.client.fetch_data()
        except PyEboxError as exp:
            _LOGGER.error("Error on receive last EBox data: %s", exp)
            return
        # Update data
        self.data = self.client.get_data()
Esempio n. 5
0
class EBoxData:
    """Get data from Ebox."""

    def __init__(self, username, password, httpsession):
        """Initialize the data object."""
        from pyebox import EboxClient
        self.client = EboxClient(username, password,
                                 REQUESTS_TIMEOUT, httpsession)
        self.data = {}

    @Throttle(MIN_TIME_BETWEEN_UPDATES)
    async def async_update(self):
        """Get the latest data from Ebox."""
        from pyebox.client import PyEboxError
        try:
            await self.client.fetch_data()
        except PyEboxError as exp:
            _LOGGER.error("Error on receive last EBox data: %s", exp)
            return
        # Update data
        self.data = self.client.get_data()
Esempio n. 6
0
 def __init__(self, username, password, httpsession):
     """Initialize the data object."""
     from pyebox import EboxClient
     self.client = EboxClient(username, password,
                              REQUESTS_TIMEOUT, httpsession)
     self.data = {}
Esempio n. 7
0
def main():
    """Main function"""
    parser = argparse.ArgumentParser()
    parser.add_argument('-u', '--username',
                        required=True, help='EBox account')
    parser.add_argument('-p', '--password',
                        required=True, help='Password')
    parser.add_argument('-j', '--json', action='store_true',
                        default=False, help='Json output')
    parser.add_argument('-t', '--timeout',
                        default=REQUESTS_TIMEOUT, help='Request timeout')
    args = parser.parse_args()
    client = EboxClient(args.username, args.password, args.timeout)

    loop = asyncio.get_event_loop()
    task = loop.create_task(client.fetch_data())
    try:
        loop.run_until_complete(task)
    except PyEboxError as exp:
        print(exp)
        client.close_session()
        return
    if not client.get_data():
        client.close_session()
        return
    if args.json:
        print(json.dumps(client.get_data()))
    else:
        _format_output(args.username, client.get_data())
    client.close_session()