Merge pull request #21 from cclauss/patch-1
GitHub Action to lint Python code
This commit is contained in:
commit
011c1b1448
23
.github/workflows/lint_python.yml
vendored
Normal file
23
.github/workflows/lint_python.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
name: lint_python
|
||||||
|
on: [pull_request, push]
|
||||||
|
jobs:
|
||||||
|
lint_python:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
- run: pip install --upgrade pip wheel
|
||||||
|
- run: pip install bandit black codespell flake8 flake8-bugbear
|
||||||
|
flake8-comprehensions isort mypy pytest pyupgrade safety
|
||||||
|
- run: bandit --recursive --skip B311,B605 .
|
||||||
|
- run: black --check . || true
|
||||||
|
- run: codespell
|
||||||
|
- run: flake8 . --count --max-complexity=19 --max-line-length=88 --show-source --statistics
|
||||||
|
- run: isort --check-only --profile black .
|
||||||
|
- run: pip install -r requirements.txt || pip install --editable . || true
|
||||||
|
- run: mkdir --parents --verbose .mypy_cache
|
||||||
|
- run: mypy --ignore-missing-imports --install-types --non-interactive .
|
||||||
|
- run: pytest . || true
|
||||||
|
- run: pytest --doctest-modules . || true
|
||||||
|
- run: shopt -s globstar && pyupgrade --py36-plus **/*.py
|
||||||
|
- run: safety check
|
||||||
121
Jarvis2.py
121
Jarvis2.py
@ -1,39 +1,45 @@
|
|||||||
import pyttsx3
|
|
||||||
import speech_recognition as sr
|
|
||||||
import datetime
|
import datetime
|
||||||
import wikipedia
|
|
||||||
import webbrowser
|
|
||||||
import os
|
import os
|
||||||
|
import random
|
||||||
import smtplib
|
import smtplib
|
||||||
import sys
|
import sys
|
||||||
import random
|
import webbrowser
|
||||||
|
|
||||||
|
import pyttsx3
|
||||||
|
import speech_recognition as sr
|
||||||
|
import wikipedia
|
||||||
|
|
||||||
print("Initializing Jarvis....")
|
print("Initializing Jarvis....")
|
||||||
MASTER = "Harsha"
|
MASTER = "Harsha"
|
||||||
|
|
||||||
|
|
||||||
engine = pyttsx3.init('nsss')
|
engine = pyttsx3.init("nsss")
|
||||||
voices = engine.getProperty('voices')
|
voices = engine.getProperty("voices")
|
||||||
engine.setProperty('voice', voices[0].id)
|
engine.setProperty("voice", voices[0].id)
|
||||||
popular_websites = {'google': 'https://www.google.com',
|
popular_websites = {
|
||||||
'youtube': 'https://www.youtube.com',
|
"google": "https://www.google.com",
|
||||||
'wikipedia': 'https://www.wikipedia.org',
|
"youtube": "https://www.youtube.com",
|
||||||
'amazon': 'https://www.amazon.com'}
|
"wikipedia": "https://www.wikipedia.org",
|
||||||
search_engines = {'google': 'https://www.google.com',
|
"amazon": "https://www.amazon.com",
|
||||||
'youtube': 'https://www.youtube.com',
|
}
|
||||||
'bing': 'https://www.bing.com'}
|
search_engines = {
|
||||||
|
"google": "https://www.google.com",
|
||||||
|
"youtube": "https://www.youtube.com",
|
||||||
|
"bing": "https://www.bing.com",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def open_url(url):
|
def open_url(url):
|
||||||
webbrowser.open(url)
|
webbrowser.open(url)
|
||||||
chrome_path = 'open -a /Applications/Google\ Chrome.app %s'
|
chrome_path = r"open -a /Applications/Google\ Chrome.app %s"
|
||||||
webbrowser.get(chrome_path).open(url)
|
webbrowser.get(chrome_path).open(url)
|
||||||
|
|
||||||
|
|
||||||
def search(search_query, search_engine):
|
def search(search_query, search_engine):
|
||||||
try:
|
try:
|
||||||
open_url(f'{search_engines[search_engine]}/search?q={search_query}')
|
open_url(f"{search_engines[search_engine]}/search?q={search_query}")
|
||||||
except IndexError:
|
except IndexError:
|
||||||
open_url(f'https://www.google.com/search?q={search_query}')
|
open_url(f"https://www.google.com/search?q={search_query}")
|
||||||
|
|
||||||
|
|
||||||
def speak(text):
|
def speak(text):
|
||||||
@ -58,6 +64,7 @@ def wishMe():
|
|||||||
|
|
||||||
# This is where our programme begins....
|
# This is where our programme begins....
|
||||||
|
|
||||||
|
|
||||||
def takeCommand():
|
def takeCommand():
|
||||||
r = sr.Recognizer()
|
r = sr.Recognizer()
|
||||||
with sr.Microphone() as source:
|
with sr.Microphone() as source:
|
||||||
@ -68,7 +75,7 @@ def takeCommand():
|
|||||||
query = " "
|
query = " "
|
||||||
try:
|
try:
|
||||||
print("Recognizing....")
|
print("Recognizing....")
|
||||||
query = r.recognize_google(audio, language='en-in')
|
query = r.recognize_google(audio, language="en-in")
|
||||||
print("user said: " + query)
|
print("user said: " + query)
|
||||||
|
|
||||||
except sr.UnknownValueError:
|
except sr.UnknownValueError:
|
||||||
@ -87,70 +94,72 @@ wishMe()
|
|||||||
query = takeCommand()
|
query = takeCommand()
|
||||||
|
|
||||||
# logic for executing basic tasks
|
# logic for executing basic tasks
|
||||||
if 'wikipedia' in query.lower():
|
if "wikipedia" in query.lower():
|
||||||
speak('Searching wikipedia....')
|
speak("Searching wikipedia....")
|
||||||
query = query.replace("wikipedia", "")
|
query = query.replace("wikipedia", "")
|
||||||
results = wikipedia.summary(query, sentences=2)
|
results = wikipedia.summary(query, sentences=2)
|
||||||
print(results)
|
print(results)
|
||||||
speak(results)
|
speak(results)
|
||||||
|
|
||||||
elif "what\'s up" in query or 'how are you' in query:
|
elif "what's up" in query or "how are you" in query:
|
||||||
stMsgs = ['Just doing my thing!', 'I am fine!',
|
stMsgs = [
|
||||||
'Nice!', 'I am nice and full of energy']
|
"Just doing my thing!",
|
||||||
|
"I am fine!",
|
||||||
|
"Nice!",
|
||||||
|
"I am nice and full of energy",
|
||||||
|
]
|
||||||
speak(random.choice(stMsgs))
|
speak(random.choice(stMsgs))
|
||||||
|
|
||||||
elif 'open' in query.lower():
|
elif "open" in query.lower():
|
||||||
website = query.replace('open', '').strip().lower()
|
website = query.replace("open", "").strip().lower()
|
||||||
try:
|
try:
|
||||||
open_url(popular_websites[website])
|
open_url(popular_websites[website])
|
||||||
except IndexError: # If the website is unknown
|
except IndexError: # If the website is unknown
|
||||||
print(f'Unknown website: {website}')
|
print(f"Unknown website: {website}")
|
||||||
speak(f'Sorry, i don\'t know the website {website}')
|
speak(f"Sorry, i don't know the website {website}")
|
||||||
|
|
||||||
elif 'search' in query.lower():
|
elif "search" in query.lower():
|
||||||
search_query = query.split('for')[-1]
|
search_query = query.split("for")[-1]
|
||||||
search_engine = query.split('for')[0].replace('search', '').strip().lower()
|
search_engine = query.split("for")[0].replace("search", "").strip().lower()
|
||||||
search(search_query, search_engine)
|
search(search_query, search_engine)
|
||||||
|
|
||||||
|
elif "email" in query:
|
||||||
elif 'email' in query:
|
speak("Who is the recipient? ")
|
||||||
speak('Who is the recipient? ')
|
|
||||||
recipient = takeCommand()
|
recipient = takeCommand()
|
||||||
|
|
||||||
if 'me' in recipient:
|
if "me" in recipient:
|
||||||
try:
|
try:
|
||||||
speak('What should I say? ')
|
speak("What should I say? ")
|
||||||
content = takeCommand()
|
content = takeCommand()
|
||||||
|
|
||||||
server = smtplib.SMTP('smtp.gmail.com', 587)
|
server = smtplib.SMTP("smtp.gmail.com", 587)
|
||||||
server.ehlo()
|
server.ehlo()
|
||||||
server.starttls()
|
server.starttls()
|
||||||
server.login("Your_Username", 'Your_Password')
|
server.login("Your_Username", "Your_Password")
|
||||||
server.sendmail('Your_Username', "Recipient_Username", content)
|
server.sendmail("Your_Username", "Recipient_Username", content)
|
||||||
server.close()
|
server.close()
|
||||||
speak('Email sent!')
|
speak("Email sent!")
|
||||||
|
except Exception:
|
||||||
|
speak("Sorry Sir! I am unable to send your message at this moment!")
|
||||||
|
|
||||||
except:
|
elif "nothing" in query or "abort" in query or "stop" in query:
|
||||||
speak('Sorry Sir! I am unable to send your message at this moment!')
|
speak("okay")
|
||||||
|
speak("Bye Sir, have a good day.")
|
||||||
elif 'nothing' in query or 'abort' in query or 'stop' in query:
|
|
||||||
speak('okay')
|
|
||||||
speak('Bye Sir, have a good day.')
|
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
elif 'hello' in query:
|
elif "hello" in query:
|
||||||
speak('Hello Sir')
|
speak("Hello Sir")
|
||||||
|
|
||||||
elif 'bye' in query:
|
elif "bye" in query:
|
||||||
speak('Bye Sir, have a good day.')
|
speak("Bye Sir, have a good day.")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
elif 'play music' in query:
|
elif "play music" in query:
|
||||||
music_folder = 'Your_music_folder_path(absolute_path)'
|
music_folder = "Your_music_folder_path(absolute_path)"
|
||||||
music = ['music1', 'music2', 'music3', 'music4','music5']
|
music = ("music1", "music2", "music3", "music4", "music5")
|
||||||
random_music = music_folder + random.choice(music) + '.mp3'
|
random_music = music_folder + random.choice(music) + ".mp3"
|
||||||
os.system(random_music)
|
os.system(random_music)
|
||||||
|
|
||||||
speak('Playing your request')
|
speak("Playing your request")
|
||||||
|
|
||||||
speak('Next Command! Sir!')
|
speak("Next Command! Sir!")
|
||||||
|
|||||||
@ -1,40 +1,46 @@
|
|||||||
import pyttsx3
|
|
||||||
import speech_recognition as sr
|
|
||||||
import datetime
|
import datetime
|
||||||
import wikipedia
|
import random
|
||||||
import webbrowser
|
|
||||||
import os
|
|
||||||
import smtplib
|
import smtplib
|
||||||
import sys
|
import sys
|
||||||
import random
|
import webbrowser
|
||||||
|
|
||||||
|
import pyttsx3
|
||||||
|
import speech_recognition as sr
|
||||||
|
import wikipedia
|
||||||
from pygame import mixer
|
from pygame import mixer
|
||||||
|
|
||||||
mixer.init()
|
mixer.init()
|
||||||
|
|
||||||
print("Initializing Jarvis....")
|
print("Initializing Jarvis....")
|
||||||
MASTER = "Tony Stark"
|
MASTER = "Tony Stark"
|
||||||
|
|
||||||
engine = pyttsx3.init('sapi5') #
|
engine = pyttsx3.init("sapi5")
|
||||||
voices = engine.getProperty('voices')
|
voices = engine.getProperty("voices")
|
||||||
engine.setProperty('voice', voices[0].id)
|
engine.setProperty("voice", voices[0].id)
|
||||||
popular_websites = {'google': 'https://www.google.com',
|
popular_websites = {
|
||||||
'youtube': 'https://www.youtube.com',
|
"google": "https://www.google.com",
|
||||||
'wikipedia': 'https://www.wikipedia.org',
|
"youtube": "https://www.youtube.com",
|
||||||
'amazon': 'https://www.amazon.com'}
|
"wikipedia": "https://www.wikipedia.org",
|
||||||
search_engines = {'google': 'https://www.google.com',
|
"amazon": "https://www.amazon.com",
|
||||||
'youtube': 'https://www.youtube.com',
|
}
|
||||||
'bing': 'https://www.bing.com'}
|
search_engines = {
|
||||||
|
"google": "https://www.google.com",
|
||||||
|
"youtube": "https://www.youtube.com",
|
||||||
|
"bing": "https://www.bing.com",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def open_url(url):
|
def open_url(url):
|
||||||
webbrowser.open(url)
|
webbrowser.open(url)
|
||||||
chrome_path = 'open -a /Applications/Google\ Chrome.app %s'
|
chrome_path = r"open -a /Applications/Google\ Chrome.app %s"
|
||||||
webbrowser.get(chrome_path).open(url)
|
webbrowser.get(chrome_path).open(url)
|
||||||
|
|
||||||
|
|
||||||
def search(search_query, search_engine):
|
def search(search_query, search_engine):
|
||||||
try:
|
try:
|
||||||
open_url(f'{search_engines[search_engine]}/search?q={search_query}')
|
open_url(f"{search_engines[search_engine]}/search?q={search_query}")
|
||||||
except IndexError:
|
except IndexError:
|
||||||
open_url(f'https://www.google.com/search?q={search_query}')
|
open_url(f"https://www.google.com/search?q={search_query}")
|
||||||
|
|
||||||
|
|
||||||
def speak(text):
|
def speak(text):
|
||||||
@ -68,7 +74,7 @@ def takeCommand():
|
|||||||
query = " "
|
query = " "
|
||||||
try:
|
try:
|
||||||
print("Recognizing....")
|
print("Recognizing....")
|
||||||
query = r.recognize_google(audio, language='en-in')
|
query = r.recognize_google(audio, language="en-in")
|
||||||
print("user said: " + query)
|
print("user said: " + query)
|
||||||
|
|
||||||
except sr.UnknownValueError:
|
except sr.UnknownValueError:
|
||||||
@ -88,78 +94,81 @@ while True:
|
|||||||
query = takeCommand()
|
query = takeCommand()
|
||||||
|
|
||||||
# logic for executing basic tasks
|
# logic for executing basic tasks
|
||||||
if 'wikipedia' in query.lower():
|
if "wikipedia" in query.lower():
|
||||||
speak('Searching wikipedia....')
|
speak("Searching wikipedia....")
|
||||||
query = query.replace("wikipedia", "")
|
query = query.replace("wikipedia", "")
|
||||||
results = wikipedia.summary(query, sentences=2)
|
results = wikipedia.summary(query, sentences=2)
|
||||||
print(results)
|
print(results)
|
||||||
speak(results)
|
speak(results)
|
||||||
|
|
||||||
elif "what\'s up" in query or 'how are you' in query:
|
elif "what's up" in query or "how are you" in query:
|
||||||
stMsgs = ['Just doing my thing!', 'I am fine!',
|
stMsgs = [
|
||||||
'Nice!', 'I am nice and full of energy']
|
"Just doing my thing!",
|
||||||
|
"I am fine!",
|
||||||
|
"Nice!",
|
||||||
|
"I am nice and full of energy",
|
||||||
|
]
|
||||||
speak(random.choice(stMsgs))
|
speak(random.choice(stMsgs))
|
||||||
|
|
||||||
elif 'open' in query.lower():
|
elif "open" in query.lower():
|
||||||
website = query.replace('open', '').strip().lower()
|
website = query.replace("open", "").strip().lower()
|
||||||
try:
|
try:
|
||||||
open_url(popular_websites[website])
|
open_url(popular_websites[website])
|
||||||
except IndexError: # If the website is unknown
|
except IndexError: # If the website is unknown
|
||||||
print(f'Unknown website: {website}')
|
print(f"Unknown website: {website}")
|
||||||
speak(f'Sorry, i don\'t know the website {website}')
|
speak(f"Sorry, i don't know the website {website}")
|
||||||
|
|
||||||
elif 'search' in query.lower():
|
elif "search" in query.lower():
|
||||||
search_query = query.split('for')[-1]
|
search_query = query.split("for")[-1]
|
||||||
search_engine = query.split('for')[0].replace('search', '').strip().lower()
|
search_engine = query.split("for")[0].replace("search", "").strip().lower()
|
||||||
search(search_query, search_engine)
|
search(search_query, search_engine)
|
||||||
|
|
||||||
elif 'mail' in query:
|
elif "mail" in query:
|
||||||
speak('Who is the recipient? ')
|
speak("Who is the recipient? ")
|
||||||
recipient = takeCommand()
|
recipient = takeCommand()
|
||||||
|
|
||||||
if 'me' in recipient:
|
if "me" in recipient:
|
||||||
try:
|
try:
|
||||||
speak('What should I say? ')
|
speak("What should I say? ")
|
||||||
content = takeCommand()
|
content = takeCommand()
|
||||||
|
|
||||||
server = smtplib.SMTP('smtp.gmail.com', 587)
|
server = smtplib.SMTP("smtp.gmail.com", 587)
|
||||||
server.ehlo()
|
server.ehlo()
|
||||||
server.starttls()
|
server.starttls()
|
||||||
server.login("Your_Username", 'Your_Password')
|
server.login("Your_Username", "Your_Password")
|
||||||
server.sendmail('Your_Username', "Recipient_Username", content)
|
server.sendmail("Your_Username", "Recipient_Username", content)
|
||||||
server.close()
|
server.close()
|
||||||
speak('Email sent!')
|
speak("Email sent!")
|
||||||
|
except Exception:
|
||||||
|
speak("Sorry Sir! I am unable to send your message at this moment!")
|
||||||
|
|
||||||
except:
|
elif "nothing" in query or "abort" in query or "stop" in query:
|
||||||
speak('Sorry Sir! I am unable to send your message at this moment!')
|
speak("okay")
|
||||||
|
speak("Bye Sir, have a good day.")
|
||||||
elif 'nothing' in query or 'abort' in query or 'stop' in query:
|
|
||||||
speak('okay')
|
|
||||||
speak('Bye Sir, have a good day.')
|
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
elif 'hello' in query:
|
elif "hello" in query:
|
||||||
speak('Hello Sir')
|
speak("Hello Sir")
|
||||||
|
|
||||||
elif 'bye' in query:
|
elif "bye" in query:
|
||||||
speak('Bye Sir, have a good day.')
|
speak("Bye Sir, have a good day.")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
elif 'play music' in query:
|
elif "play music" in query:
|
||||||
music_folder = "Your_music_folder_path(absolute_path)"
|
music_folder = "Your_music_folder_path(absolute_path)"
|
||||||
music = ['music1', 'music2', 'music3', 'music4']
|
music = ("music1", "music2", "music3", "music4")
|
||||||
random_music = music_folder + random.choice(music) + '.mp3'
|
random_music = music_folder + random.choice(music) + ".mp3"
|
||||||
speak('Playing your request')
|
speak("Playing your request")
|
||||||
mixer.music.load(random_music)
|
mixer.music.load(random_music)
|
||||||
mixer.music.play()
|
mixer.music.play()
|
||||||
|
|
||||||
elif 'pause music' in query:
|
elif "pause music" in query:
|
||||||
mixer.music.pause()
|
mixer.music.pause()
|
||||||
|
|
||||||
elif 'stop music' in query:
|
elif "stop music" in query:
|
||||||
mixer.music.stop()
|
mixer.music.stop()
|
||||||
|
|
||||||
elif 'unpause' in query:
|
elif "unpause" in query:
|
||||||
mixer.music.unpause()
|
mixer.music.unpause()
|
||||||
|
|
||||||
speak('Next Command! Sir!')
|
speak("Next Command! Sir!")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user