rename includes/converter.py -> includes/helper/freqConverter.py

This commit is contained in:
JHCD 2015-07-31 19:20:05 +02:00
parent e7b5bffdd3
commit e26fc45313
2 changed files with 5 additions and 5 deletions

View file

@ -0,0 +1,29 @@
#!/usr/bin/python
# -*- coding: UTF-8 -*-
#
"""
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()")