Beispiel #1
0
 def test_gai_error(self, mock):
     mock.side_effect = gaierror
     ntp_now, fetched = now()
     self.assertEqual(mock.call_count,
                      self.poolservers)
     self.assertFalse(fetched)  # Not fetched from NTP server
     self.assertTrue(isinstance(ntp_now, datetime))
Beispiel #2
0
 def test_ntp_exception(self, mock):
     mock.side_effect = NTPException
     ntp_now, fetched = now()
     self.assertEqual(mock.call_count,
                      self.poolservers)
     self.assertFalse(fetched)  # Not fetched from NTP server
     self.assertTrue(isinstance(ntp_now, datetime))
Beispiel #3
0
 def test_instance(self, mock):
     ntp_dt = ntpdatetime(2002, 12, 25)
     self.assertTrue(isinstance(ntp_dt, datetime))
     mock.return_value = NTPStats()
     ntp_now, fetched = now()
     self.assertTrue(fetched)  # Fetched from NTP server
     self.assertTrue(isinstance(ntp_now, datetime))
Beispiel #4
0
 def done(self,serial_number1,serial_number2):
     tmp = now()[0].strftime('%d-%m-%Y %H:%M:%S')
     serial_centre.detail.ix[serial_number1-1, 6] = tmp
     serial_centre.detail.ix[serial_number2-1, 6] = tmp
Beispiel #5
0
 def __init__(self,account,type,stock,price,quantity):
     serial_number = serial_centre.trade()
     serial_centre.detail = serial_centre.detail.append(
         pd.Series([serial_number,account, type, stock, price, quantity,now()[0].strftime('%d-%m-%Y %H:%M:%S'),quantity, None]),ignore_index=True)
     eval(account).history.append(serial_number)
Beispiel #6
0
def get_ip():
    ntp_now, fetched = now()
    response = requests.get("http://txt.go.sohu.com/ip/soip", headers=headers)
    ip = re.findall(r'\d+.\d+.\d+.\d+', response.text)
    logger.debug('公网IP获取正常')
    return ip