2017-01-28 12:52:18 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
#
|
|
|
|
# Copyright (C) 2016,2017 The University of Sheffield, UK
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
2017-01-28 12:56:29 +00:00
|
|
|
import sys
|
|
|
|
from time import sleep
|
|
|
|
from random import randint
|
|
|
|
|
2017-01-28 13:15:05 +00:00
|
|
|
|
2017-04-09 07:20:52 +00:00
|
|
|
def google_dos_protection(max=2):
|
|
|
|
sleep(randint(1, max) * .6)
|
2017-01-28 12:56:29 +00:00
|
|
|
|
2017-01-28 13:15:05 +00:00
|
|
|
|
2017-01-28 12:56:29 +00:00
|
|
|
def log(verbose, msg):
|
|
|
|
if verbose:
|
|
|
|
sys.stdout.write(msg)
|
2017-01-28 14:49:29 +00:00
|
|
|
sys.stdout.flush()
|
2017-01-28 13:15:05 +00:00
|
|
|
|
2017-01-28 17:22:28 +00:00
|
|
|
|
2017-01-28 17:08:18 +00:00
|
|
|
def logmsg(verbose, msg1, msg2):
|
|
|
|
if verbose:
|
|
|
|
return msg1 + msg2
|
|
|
|
else:
|
|
|
|
return msg1
|
|
|
|
|
2017-01-28 17:22:28 +00:00
|
|
|
|
2017-01-28 12:56:29 +00:00
|
|
|
def valueOf(value, default):
|
|
|
|
if value is not None and value is not "":
|
|
|
|
return value
|
|
|
|
else:
|
|
|
|
return default
|