#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2014 SUSE
#
# This software is licensed to you under the GNU General Public License,
# version 2 (GPLv2). There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
# along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
#
# SUSE trademarks are not licensed under GPLv2. No permission is
# granted to use or replicate SUSE trademarks that are incorporated
# in this software or its documentation.

import socket
import sys

from spacewalk.susemanager.mgr_sync.cli import get_options
from spacewalk.susemanager.mgr_sync.mgr_sync import MgrSync


options = get_options()

try:
    sys.exit(MgrSync().run(options))
except socket.error, ex:
    sys.stderr.write("Network error: {0}\n".format(ex))
    if options.verbose:
        raise
    else:
        sys.exit(1)
except KeyboardInterrupt, ex:
    sys.stdout.write("\n")
except Exception, ex:
    sys.stderr.write("General error: {0}\n".format(ex))
    if options.verbose:
        raise
    else:
        sys.exit(1)
