Python- Google voice - python

I am trying to use http://sphinxdoc.github.io/pygooglevoice/examples.html#send-sms-messages and I am getting the error
File "build/bdist.macosx-10.6-intel/egg/googlevoice/voice.py", line 72, in login
AttributeError: 'NoneType' object has no attribute 'group'
My code is:
from googlevoice import Voice
from googlevoice.util import input
import sys
username, password = "email#gmail.com", "password"
voice = Voice()
voice.login(username, password)
phoneNumber = input('Number to send message to: ')
text = input('Message text: ')
voice.send_sms(phoneNumber, text)
I was wondering if that is a login error or error in the code? If so, how can I edit the code so that it works?
Thank you so much!
EDIT: I have been researching this and apparently it's a common problem and I have to change line 72 in the file voice.py but I can't find the file:
/usr/local/lib/python2.7/dist-packages/googlevoice/voice.py
To install, I did:
$ pip install python python-setuptools
$ sudo easy_install simplejson
$ sudo easy_install -U pygooglevoice
And now I can't find the voice.py file. I have been looking for a while on my mac but found nothing.
Other questions with the same problem:
https://code.google.com/archive/p/pygooglevoice/issues/76
googlevoice will not programatically login (Python)
python: pygooglevoice unable to login
Please please please help!

After struggling through errors and replacing the one line (which never worked...) I downloaded https://github.com/pettazz/pygooglevoice and put the googlevoice file in the same file I was working on. Hope this helps anyone with the same question.

Related

Renpy, an exception when trying to build a build on Android (renpy.loader.transfn)

Let's say there is a json file in ./resources called "string.json". Then the parsing of this file can be implemented as follows:
label start:
$ import json
$ f = open(renpy.loader.transfn("resources/string.json"))
$ text = json.load(f)
On a PC and on an Android emulator, this script will work fine, but when I build the build and run it on my phone, an exception is thrown:
exception an Android phone
How I can fix it?
Thanks a lot for answer and sorry my english is not good enough.
The renpy.file method can be used to resolve the exception:
label start:
$ import json
$ f = renpy.file("resources/string.json")
$ text = json.load(f)

OSError: Unable to upload

I'm havin a rough time trying to fgure this error out. Y try ro run a simple script like the these:
from instapy_cli import client
username = "username"
password = "password"
image = "Image.jpg"
description = "This is a test"
with client(username, password) as cli:
cli.upload(image, description)
and i get the following error:
[IG] not found cookie/cookie_file >> login as default
Error parsing error response: Expecting value: line 1 column 1 (char 0)
Error is >>
Bad Request
Something went bad.
Please retry or send an issue on https://github.com/b3nab/instapy-cli
Traceback (most recent call last):
File "c:/Users/Lucas/Desktop/Python/Proyectos/Insta Automation/Matetemático/Posting Script.py", line 15, in <module>
cli.upload(imagen, text)
File "C:\Users\Lucas\AppData\Roaming\Python\Python37\site-packages\instapy_cli\cli.py", line 153, in upload
raise IOError("Unable to upload.")
OSError: Unable to upload.
I was facing the same issue, and I solved it by uninstalling and then re-installing:
pip uninstall instapy-cli
pip install instapy-cli
install these packages should be greater than a specific version
[instabot 0.117.0 requires moviepy>=1.0.1, but you have moviepy 0.2.3.2 which is incompatible.
instabot 0.117.0 requires tqdm>=4.41.1, but you have tqdm 4.11.2 which is incompatible]
try this

Getting currently playing song with Spotipy gives error: "'Spotify' object has no attribute 'currently_playing'"

I'm programming a script that returns your currently playing song from Spotify.
I read the documentation from Spotify API and everything is working well but I have some problems trying to implement some modules.
For example here https://spotipy.readthedocs.io/en/latest/ said that there's a module called currently_playing() but I get this error:
Traceback (most recent call last):
File "spotify_test.py", line 21, in <module>
current_song = sp.currently_playing()
AttributeError: 'Spotify' object has no attribute 'currently_playing'
By far, this is my code, it works well when I change the scope and the module to obtain the playlists of a user. So the token is not the problem.
import sys
import spotipy
import spotipy.util as util
if len(sys.argv) > 1:
username = sys.argv[1]
else:
print('Usage %s Username ' % (sys.argv[0],))
sys.exit()
scope = 'user-read-currently-playing'
token = spotipy.util.prompt_for_user_token(
username, scope, redirect_uri='http://127.0.0.1/callback')
if token:
sp = spotipy.Spotify(auth=token)
current_song = sp.currently_playing()
else:
print("Can't get token for", username)
print(current_song)
Even if PyPi claims that the version of Spotipy is the latest there, 2.4.4, in fact, it is not. I noticed that after installing Spotipy with pip, its source code is different from the head of the master branch on the GitHub. And the PyPi version doesn't have the currently_playing method.
What worked for me is to uninstall Spotipy by running pip uninstall spotipy and to install it again directly from GitHub:
pip install git+https://github.com/plamere/spotipy.git#master

Error using Google Assistant Library with Raspberry Pi 3 and Python (Credentials not accepted)

I successfully managed to get Google's Assistant working on my Raspberry Pi 3. It works by using
google-assistant-demo --d device_id1234
Now I want to get access with python to turn on/off an LED when a certain command is recognized. Unfortunately the page I followed isn't free, so I can't provide a link. The problematic part of my code is the following:
def main():
parser = argparse.ArgumentParser(
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('--credentials', type=existing_file,
metavar='OAUTH2_CREDENTIALS_FILE',
default=os.path.join(
os.path.expanduser('~/.config'),
'google-oauthlib-tool',
'credentials.json'
),
help='Path to store and read OAuth2 credentials')
args = parser.parse_args()
with open(args.credentials, 'r') as f:
credentials = google.oauth2.credentials.Credentials(token=None,
**json.load(f))
with Assistant(credentials) as assistant:
print("Warte auf Hotword")
for event in assistant.start():
process_event(event, assistant)
and when I run the script by
python assistant.py --credentials client_secret_blabla.json
it throws the error
Traceback (most recent call last):
File "assistant.py", line 137, in <module>
main()
File "assistant.py", line 128, in main
**json.load(f)
TypeError: __init__() got an unexpected keyword argument 'installed'
I tried to reinstall everything and also redownloaded the json file. Obviously the json doesn't get recognized properly, but I don't have any clue what to do. My JSON looks like this:
{"installed":{"client_id":"XXX.apps.googleusercontent.com","project_id":"dotted-nature-182957","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"XXX","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}}
here is what the Credentials class is expecting:
http://google-auth.readthedocs.io/en/latest/reference/google.oauth2.credentials.html
I hope you guys can help me with this. Thanks a lot in advance!
I just figured it out. The problem was that I was using the wrong json file. I find the documentation kind of unclear concerning that. The JSON file you have to hand over to the python script is the one which is downloaded when executing
google-oauthlib-tool --client-secrets /home/pi/PREVIOUSLYDOWNLOADEDJSON.json --scope https://www.googleapis.com/auth/assistant-sdk-prototype --save --headless
which is located at /home/pi/.config/google-oauthlib-tool/ in default.

Python Psphere Issue

Looking at using psphere. I've successfully installed it via pip but run into an issue when I execute the following code (taken from the psphere documentation site):
from psphere.client import Client
from psphere.managedobjects import HostSystem
Client = Client("server", "username", "password")
hs_list = HostSystem.all(Client)
len(hs_list)
After running that command I get the following:
"could not found expected ':'", self.get_mark())
yaml.scanner.ScannerError: while scanning a simple key
in "C:\Users\thor/.psphere/config.yaml", line 5, column 1
could not found expected ':'
in "C:\Users\thor/.psphere/config.yaml", line 6, column 1
There was no .psphere directory or config.yaml. I created both and no joy (although I must be honest - I don't really know what should be in the yaml file.)
There are no : in my file so I don't know why it's raising an exception.
Help would be appreciated. Thanks.
in the distribution's examples/ directory there is a sample_config.yaml file you can use.
# Copy this file into ~/.psphree/config.yaml and edit to your liking
general:
server: your.esxserver.com
username: Administrator
password: strongpassword
template_dir: ~/.psphere/templates/
logging:
destination: ~/.psphere/psphere.log
level: INFO # DEBUG, INFO, etc

Categories