Exemple #1
0
def main():
    """Runs the main loop of the code"""
    # Get user's name
    user_name = input('What is their name? ')
    # Wait for the command to run the first recording
    user_input.loop_for_input(DURATION_OF_TASK, INTERVAL_FOR_INPUT)
    # Wait for the command to run the second recording
    # Wait for the command to run the third recording
    # Write out the csv
    csv_writer.write_data(user_name)
    # Should main re-run?
    should_re_run = input('Is there another user? ')
    if should_re_run == 'y' or should_re_run == 'yes':
        main()
Exemple #2
0
# Ignore if not a keyboard event
if lines.partition('keyboard')[2] == "" and lines.partition('Keyboard')[2] == "":
            sys.exit()

# securityEventCode, Tec sum, Raw data
csv_data = []
# securityEventCode (security problem id)
csv_data.append("%SECURITY_PROBLEM_UID%")

# find keyword
# select text from keyword until end of line
before_keyword, keyword, after_keyword = lines.partition('input:')
if after_keyword != "":
    splittet_lines = after_keyword.splitlines()
    if len(splittet_lines) > 0:
        # Tec sum
        csv_data.append("'" + splittet_lines[0] + "'")
    else:
        sys.exit()
else:
    sys.exit()

log_data = before_keyword[-1000:] + keyword + after_keyword[:1000]

log_data = log_data.replace('\n', ' ').replace('\r', '').replace(',', '')

# Raw data
csv_data.append("'" + log_data + "'")

csv_writer.write_data(csv_data)
# Get lines from syslog
fname = "/var/log/syslog"
lines = log_read.read(300, fname)


# Ignore if not a keyboard event
if (lines.partition('keyboard')[2] == "" and
    lines.partition('Keyboard')[2] == ""):
        sys.exit()

# securityEventCode, Tec sum, Raw data
csv_data = []
# securityEventCode (security problem id)
csv_data.append("%SECURITY_PROBLEM_UID%")

# find keyword
# select text from keyword until end of line
before_keyword, keyword, after_keyword = lines.partition('input:')
if after_keyword != "":
    splittet_lines = after_keyword.splitlines()
    if(len(splittet_lines) > 0):
        # Tec sum
        csv_data.append("'" + splittet_lines[0] + "'")

lines = lines.replace('\n', ' ').replace('\r', '').replace(',', '')

# Raw data
csv_data.append("'" + lines + "'")

csv_writer.write_data(csv_data)
Exemple #4
0
import requests
from bs4 import BeautifulSoup
from csv_writer import write_data
from datetime import date
today_date=date.today()
d1=today_date.strftime("%d-%m-%Y")
url="https://www.bankbazaar.com/gold-rate-mumbai.html"
page=requests.get(url)
soup=BeautifulSoup(page.content,'html.parser')
strong=soup.find('strong',class_="bigfont")
price_22=strong.text[3:]
price_22=price_22.replace(',','')
price_22=int(price_22)*10
filename="gold_rates.csv"
write_data(filename,price_22,d1)