# Copyright 2018 - The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. r"""Instance class. Define the instance class used to hold details about an AVD instance. The instance class will hold details about AVD instances (remote/local) used to enable users to understand what instances they've created. This will be leveraged for the list, delete, and reconnect commands. The details include: - instance name (for remote instances) - creation date/instance duration - instance image details (branch/target/build id) - and more! """ import datetime import logging import re import subprocess # pylint: disable=import-error import dateutil.parser import dateutil.tz from acloud.internal import constants from acloud.internal.lib import utils from acloud.internal.lib.adb_tools import AdbTools logger = logging.getLogger(__name__) _MSG_UNABLE_TO_CALCULATE = "Unable to calculate" _RE_GROUP_ADB = "local_adb_port" _RE_GROUP_VNC = "local_vnc_port" _RE_SSH_TUNNEL_PATTERN = (r"((.*\s*-L\s)(?P<%s>\d+):127.0.0.1:%s)" r"((.*\s*-L\s)(?P<%s>\d+):127.0.0.1:%s)" r"(.+%s)") _RE_TIMEZONE = re.compile(r"^(?P