# -*- coding: utf-8 -*-
from setuphelpers import *
from setupdevhelpers import *
import glob
import json
import os


def update_package():
    # Declaration of local variables
    package_updated = False
    proxies = get_proxies_from_wapt_console()
    if not proxies:
        proxies = get_proxies()

    url_download = "https://dl.google.com/dl/google-apps-sync/x64/enterprise_gsync.msi"
    filename = url_download.split("/")[-1]

    wget(url_download, filename, proxies=proxies)

    last_version = get_msi_properties(filename)["ProductVersion"] 
    if Version(last_version) > control.get_software_version():
        package_updated = True  

        control.set_software_version(last_version)
        control.save_control_to_wapt()

    return package_updated