# Path: pyanaconda/iutil.py
# def augmentEnv():
# def _run_program(argv, root='/', stdin=None, stdout=None, env_prune=None, log_output=True, binary_output=False):
#     def chroot():
# def setSysroot(path):
# def getSysroot():
# def execInSysimageRoot(command, argv, **kwargs):
# def execWithRedirect(command, argv, stdin=None, stdout=None,
#                      stderr=None, root='/', env_prune=[], log_output=True, binary_output=False):
# def execWithCapture(command, argv, stdin=None, stderr=None, root='/',
#                     fatal=False, log_output=True):
# def execReadlines(command, argv, stdin=None, root='/', env_prune=None):
#     def queue_lines(out, queue):
#     def chroot():
# def execConsole():
# def getDirSize(dir):
#     def getSubdirSize(dir):
# def mkdirChain(dir):
# def get_active_console(dev="console"):
# def isConsoleOnVirtualTerminal(dev="console"):
# def strip_markup(text):
# def reIPL(ipldev):
# def resetRpmDb():
# def parseNfsUrl(nfsurl):
# def add_po_path(module, dir):
# def setup_translations(module):
# def fork_orphan():
# def _run_systemctl(command, service):
# def start_service(service):
# def stop_service(service):
# def restart_service(service):
# def service_running(service):
# def dracut_eject(device):
# def vtActivate(num):
#     def __init__(self, url=None, protocol="http://", host=None, port="3128",
#                  username=None, password=None):
#     def parse_url(self):
#     def parse_components(self):
#     def dict(self):
#     def __str__(self):
# def getdeepattr(obj, name):
# def setdeepattr(obj, name, value):
# def strip_accents(s):
# def cmp_obj_attrs(obj1, obj2, attr_list):
# def dir_tree_map(root, func, files=True, dirs=True):
# def chown_dir_tree(root, uid, gid, from_uid_only=None, from_gid_only=None):
#     def conditional_chown(path, uid, gid, from_uid=None, from_gid=None):
# def is_unsupported_hw():
# def upcase_first_letter(text):
#     def __init__(self, **kwargs):
#     def __getattr__(self, attr):
#     def __setattr__(self, attr, value):
#     def copy(self):
# def get_mount_paths(devnode):
# class ProxyStringError(Exception):
# class ProxyString(object):
# class DataHolder(dict):
# 
# Path: pyanaconda/threads.py
# class ThreadManager(object):
# class AnacondaThread(threading.Thread):
#     def __init__(self):
#     def __call__(self):
#     def add(self, obj):
#     def remove(self, name):
#     def exists(self, name):
#     def get(self, name):
#     def wait(self, name):
#     def wait_all(self):
#     def set_error(self, name, *exc_info):
#     def get_error(self, name):
#     def any_errors(self):
#     def raise_if_error(self, name):
#     def in_main_thread(self):
#     def running(self):
#     def names(self):
#     def __init__(self, *args, **kwargs):
#     def run(self, *args, **kwargs):
# def initThreading():
# 
# Path: pyanaconda/constants.py
# THREAD_SYNC_TIME_BASENAME = "AnaSyncTime"


import re
import os
import tempfile
import shutil
from pyanaconda import iutil
from pyanaconda.threads import threadMgr, AnacondaThread
from pyanaconda.constants import THREAD_SYNC_TIME_BASENAME

    """

    ret = iutil.execWithRedirect("ntpdate", [server])

    success = ret == 0

    if callback is not None:
        callback(success)

    return success

def one_time_sync_async(server, callback=None):
    """
    Asynchronously synchronize the system time with a given NTP server. This
    function is non-blocking it starts a new thread for synchronization and
    returns. Use callback argument to specify the function called when the
    new thread finishes if needed.

    :param server: NTP server
    :param callback: callback function to run after sync or failure
    :type callback: a function taking one boolean argument (success)

    """

    thread_name = "%s_%s" % (THREAD_SYNC_TIME_BASENAME, server)
    if threadMgr.get(thread_name):
        #syncing with the same server running
        return


# Path: pyanaconda/iutil.py
# def augmentEnv():
# def _run_program(argv, root='/', stdin=None, stdout=None, env_prune=None, log_output=True, binary_output=False):
#     def chroot():
# def setSysroot(path):
# def getSysroot():
# def execInSysimageRoot(command, argv, **kwargs):
# def execWithRedirect(command, argv, stdin=None, stdout=None,
#                      stderr=None, root='/', env_prune=[], log_output=True, binary_output=False):
# def execWithCapture(command, argv, stdin=None, stderr=None, root='/',
#                     fatal=False, log_output=True):
# def execReadlines(command, argv, stdin=None, root='/', env_prune=None):
#     def queue_lines(out, queue):
#     def chroot():
# def execConsole():
# def getDirSize(dir):
#     def getSubdirSize(dir):
# def mkdirChain(dir):
# def get_active_console(dev="console"):
# def isConsoleOnVirtualTerminal(dev="console"):
# def strip_markup(text):
# def reIPL(ipldev):
# def resetRpmDb():
# def parseNfsUrl(nfsurl):
# def add_po_path(module, dir):
# def setup_translations(module):
# def fork_orphan():
# def _run_systemctl(command, service):
# def start_service(service):
# def stop_service(service):
# def restart_service(service):
# def service_running(service):
# def dracut_eject(device):
# def vtActivate(num):
#     def __init__(self, url=None, protocol="http://", host=None, port="3128",
#                  username=None, password=None):
#     def parse_url(self):
#     def parse_components(self):
#     def dict(self):
#     def __str__(self):
# def getdeepattr(obj, name):
# def setdeepattr(obj, name, value):
# def strip_accents(s):
# def cmp_obj_attrs(obj1, obj2, attr_list):
# def dir_tree_map(root, func, files=True, dirs=True):
# def chown_dir_tree(root, uid, gid, from_uid_only=None, from_gid_only=None):
#     def conditional_chown(path, uid, gid, from_uid=None, from_gid=None):
# def is_unsupported_hw():
# def upcase_first_letter(text):
#     def __init__(self, **kwargs):
#     def __getattr__(self, attr):
#     def __setattr__(self, attr, value):
#     def copy(self):
# def get_mount_paths(devnode):
# class ProxyStringError(Exception):
# class ProxyString(object):
# class DataHolder(dict):
# 
# Path: pyanaconda/threads.py
# class ThreadManager(object):
# class AnacondaThread(threading.Thread):
#     def __init__(self):
#     def __call__(self):
#     def add(self, obj):
#     def remove(self, name):
#     def exists(self, name):
#     def get(self, name):
#     def wait(self, name):
#     def wait_all(self):
#     def set_error(self, name, *exc_info):
#     def get_error(self, name):
#     def any_errors(self):
#     def raise_if_error(self, name):
#     def in_main_thread(self):
#     def running(self):
#     def names(self):
#     def __init__(self, *args, **kwargs):
#     def run(self, *args, **kwargs):
# def initThreading():
# 
# Path: pyanaconda/constants.py
# THREAD_SYNC_TIME_BASENAME = "AnaSyncTime"


# Path: pyanaconda/ntp.py
import re
import os
import tempfile
import shutil
from pyanaconda import iutil
from pyanaconda.threads import threadMgr, AnacondaThread
from pyanaconda.constants import THREAD_SYNC_TIME_BASENAME


    """

    ret = iutil.execWithRedirect("ntpdate", [server])

    success = ret == 0

    if callback is not None:
        callback(success)

    return success

def one_time_sync_async(server, callback=None):
    """
    Asynchronously synchronize the system time with a given NTP server. This
    function is non-blocking it starts a new thread for synchronization and
    returns. Use callback argument to specify the function called when the
    new thread finishes if needed.

    :param server: NTP server
    :param callback: callback function to run after sync or failure
    :type callback: a function taking one boolean argument (success)

    """

    thread_name = "%s_%s" % (THREAD_SYNC_TIME_BASENAME, server)
    if threadMgr.get(thread_name):
        #syncing with the same server running
        return


    threadMgr.add(AnacondaThread(name=thread_name, target=one_time_sync,