# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
"""OTA verify client"""

import requests
import os
import sys
from ConfigParser import ConfigParser
from modules.data.proto.static_info_pb2 import VehicleInfo
import common.proto_utils as proto_utils
sys.path.append('/home/caros/secure_upgrade/python')
import secure_upgrade_export as sec_api

root_config_path = "/home/caros/secure_upgrade/config/secure_config.json"
returnCode = sec_api.init_secure_upgrade(root_config_path)
if returnCode == True:
    print 'Security environment init successfully!'
else:
    print 'Security environment init fail!'
    sys.exit(1)


def verify():
    # generate orig update package
    token_file_name = os.environ['HOME'] + '/.cache/apollo_update/auth_token'
    with open(token_file_name, 'r') as token_file:
        auth_token = token_file.read()
    sec_package = os.environ['HOME'] + '/.cache/sec_apollo_release.tar.gz'
    orig_package = os.environ['HOME'] + '/.cache/apollo_release.tar.gz'
    returnCode = sec_api.sec_upgrade_verify_package(auth_token, sec_package,
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
"""OTA verify client"""

import requests
import os
import sys
from ConfigParser import ConfigParser
from modules.data.proto.static_info_pb2 import VehicleInfo
import common.proto_utils as proto_utils
sys.path.append('/home/caros/secure_upgrade/python')
import secure_upgrade_export as sec_api

root_config_path = "/home/caros/secure_upgrade/config/secure_config.json"
returnCode = sec_api.init_secure_upgrade(root_config_path)
if returnCode == True:
    print 'Security environment init successfully!'
else:
    print 'Security environment init fail!'
    sys.exit(1)

def verify():
    # generate orig update package
    token_file_name = os.environ['HOME'] + '/.cache/apollo_update/auth_token'
    with open(token_file_name, 'r') as token_file:
        auth_token = token_file.read()
    sec_package = os.environ['HOME'] + '/.cache/sec_apollo_release.tar.gz'
    orig_package = os.environ['HOME'] + '/.cache/apollo_release.tar.gz'
    returnCode = sec_api.sec_upgrade_verify_package(auth_token,
                                                    sec_package,