Example #1
0
def currentMirror(require=True):
    global current
    global repo_name
    if current or not require:
        errorExit(
            (
                "%s is the currently used mirror.\n"
                "There is nothing to be done." % repo_name
            ),
            0
        )
Example #2
0
def currentMirror(require=True):
    global current
    global repo_name
    if current or not require:
        errorExit(
            (
                "%s is the currently used mirror.\n"
                "There is nothing to be done." % repo_name
            ),
            0
        )
Example #3
0
def notUbuntu():
    errorExit("Not an Ubuntu OS", 1)
Example #4
0
flag_number = indexZero(args.top_number)
flag_status = indexZero(args.min_status).replace('-', ' ')
if flag_status != 'unknown':
    flag_status = flag_status[0].upper() + flag_status[1:]

flag_list = args.list_only
flag_choose = args.choose
flag_ping = args.ping_only

if flag_choose and (not flag_number or flag_number < 2):
    parser.print_usage()
    errorExit(
        (
            "error: -c/--choose option requires -t/--top-number NUMBER "
            "where NUMBER is greater than 1."
        ),
        1
    )

def notUbuntu():
    errorExit("Not an Ubuntu OS", 1)

try:
    release = check_output("lsb_release -ics 2>/dev/null", shell=True)
except CalledProcessError:
    notUbuntu()
else:
    release = [s.strip() for s in release.decode('utf-8').split()]

hardware = check_output("uname -m", shell=True).strip().decode('utf-8')
Example #5
0
#!/usr/bin/env python

from socket import (socket, AF_INET, SOCK_STREAM,
                    gethostbyname, setdefaulttimeout)
from time import time
from re import search
from util_funcs import errorExit, getHTML
try:
    from bs4 import BeautifulSoup
except ImportError as err:
    errorExit(
        (
            "%s\n"
            "Try 'sudo apt-get install python-bs4' "
            "or 'sudo apt-get install python3-bs4'" % err
        ),
        1
    )

class RoundTrip:
    def __init__(self, url):
        self.url = url
        try:
            self.addr = gethostbyname(self.url)
        except IOError as err:
            print("\nCould not resolve hostname %s\n%s\n" % (self.url, err))
            self.addr = None


    def __tcpPing(self):
        """Return latency to url's resolved IP address"""
Example #6
0
def notUbuntu():
    errorExit("Not an Ubuntu OS", 1)
Example #7
0
flag_number = indexZero(args.top_number)
flag_status = indexZero(args.min_status).replace('-', ' ')
if flag_status != 'unknown':
    flag_status = flag_status[0].upper() + flag_status[1:]

flag_list = args.list_only
flag_choose = args.choose
flag_ping = args.ping_only

if flag_choose and (not flag_number or flag_number < 2):
    parser.print_usage()
    errorExit(
        (
            "error: -c/--choose option requires -t/--top-number NUMBER "
            "where NUMBER is greater than 1."
        ),
        1
    )

def notUbuntu():
    errorExit("Not an Ubuntu OS", 1)

try:
    release = check_output(["lsb_release", "-ics"])
except OSError:
    notUbuntu()
else:
    release = [s.strip() for s in release.decode('utf-8').split()]

if release[0] == 'Debian':