extract class and functions from boswatch.py to includes

This commit is contained in:
JHCD 2015-06-25 16:13:52 +02:00
parent 259239a90b
commit f58891a8ec
4 changed files with 89 additions and 57 deletions

29
includes/converter.py Normal file
View file

@ -0,0 +1,29 @@
#!/usr/bin/python
# -*- coding: cp1252 -*-
#
"""
convert frequency to Hz
@author: Bastian Schroll
"""
import logging
def freqToHz(freq):
"""
gets a frequency and resolve it in Hz
@type freq: string
@param freq: frequency of the SDR Stick
@return: frequency in Hz
@exception: Exception if Error by recalc
"""
try:
freq = freq.replace("k","e3").replace("M","e6")
# freq has to be interpreted as float first...
# otherwise you will get the error: an invalid literal for int() with base 10
return int(float(freq))
except:
logging.exception("Error in freqToHz()")