Yowsup connection to whatsapp raise Disconnected because close exception - python

I have installed the yowsub library (the latest version ) on my device ( Ubuntu 12.04 )
also I have obtained the request code by running this command
$ ./yowsup-cli --requestcode sms --config yowsup-cli.config
and then I registered it successfully using this command
$ ./yowsup-cli --register {MY-CODE} --config yowsup-cli.config
after that I entered the returned password in the configuration file.
but when I try to send messages by this command
$ ./yowsup-cli --send {Destination phone with it's country code} "Test message" --wait --config yowsup-cli.config
I have the following exception
Disconnected because close
I tried more than solution related to this issue but the result was the same exception.

I have solved the issue by downloading a new fork of the yowsube library from this link
http://mandroslabs.com/mandrosian/
and it's now working good.

Related

Yocto Project Bitbake Unexpected Termination

I just got my i.MX 8M Evaluation Kit and I followed the tutorial to make the system for my board.
I build the system on a host machine with Ubuntu 16.04 and I followed all instructions in Section-3 to set up my host machine.
I'm trying to build the Wayland image with OPTEE enabled so the commands are:
$ DISTRO=fsl-imx-wayland MACHINE=imx8mqevk source fsl-setup-release.sh -b build-wayland
Comment two SDL settings in local.conf: PACKAGECONFIG_append_pn-qemu-native = " sdl", PACKAGECONFIG_append_pn-nativesdk-qemu = " sdl"
Enable OPTEE in local.conf
$ bitbake fsl-image-qt5-validation-imx
The issue happens after the "bitbake" command, which is the script would suddenly be stopped and the host machine would be suspended and required re-login. The bitbake command can be continued with "-k" parameter while the unknown termination and re-login process are really annoying to me.
By reviewing the bitbake log file bitbake-cookerdeamon.log, I found that every time before unexpected termination, the bitbake command generates the same logs:
Accepting [<socket.socket fd=7, family=AddressFamily.AF_UNIX,
type=SocketKind.SOCK_STREAM, proto=0, laddr=bitbake.sock>] Connecting
Running command ['updateConfig', ...]
Running command ['getVariable', 'BBINCLUDELOGS']
Running command ['getVariable', 'BBINCLUDELOGS_LINES']
Running command ['getSetVariable', 'BB_CONSOLELOG']
Running command ['getUIHandlerNum']
Running command ['setEventMask', ...]
Running command ['getVariable', 'BB_DEFAULT_TASK']
Running command ['setConfig', 'cmd', 'build']
Running command ['buildTargets', ['fsl-image-qt5-validation-imx'], 'build']
Running command ['stateForceShutdown']
Connecting Client
Disconnecting Client
No timeout, exiting.
Exiting
According to my current understanding, the above commands are only supposed to be executed after all tasks have been prepared. However, right now my host machine may invoke these commands during other tasks are still running, and this incorrect sequence leads to my unexpected termination issue.
I'm wondering if anyone runs to a similar problem or knows the solution to my issue?
Any suggestion is welcomed. Thank you in advance.
Simon
-----Supplemental Information
Here is the content of the configuration file fsl-imx-wayland.conf
# i.MX DISTRO for Wayland without X11
include conf/distro/include/fsl-imx-base.inc include
conf/distro/include/fsl-imx-preferred-env.inc
DISTRO = "fsl-imx-wayland"
# Remove conflicting backends DISTRO_FEATURES_remove = "directfb x11 " DISTRO_FEATURES_append = " wayland pam systemd"

Use dkimpy from command line

How to use this python library from the command line?
https://pypi.python.org/pypi/dkimpy
I have a raw email message I want to validate the DKIM signature.. But how.. Can't find any docs about the usage
The raw message is a string/stream
First I needed a test message, this is how I got one:
Opened Gmail and selected an email.
Clicked the vertical 3 dots on the top right side of the message view
Selected Show original
Clicked Download Original and saved it to ~/original_msg.txt
I then opened up a terminal window and made sure I was in my home directory:
$ cd ~
Then I installed dkimpy:
$ pip install dkimpy
Annoyingly, dkimverify --help didn't work, but man came to the rescue:
$ man dkimverify
dkimverify(1)
NAME
dkimverify - Script for DKIM verifying messages on stdin
DESCRIPTION
dkimverify reads an RFC822 message on standard input, and returns with exit code 0
if the signature verifies successfully. Otherwise, it returns with exit code 1.
so I verified my downloaded Gmail message:
$ cat original_msg.txt | dkimverify
signature ok
$ echo $?
0
And just to make sure it failed as expected, I created a bogus message:
$ echo "bogus-header:bogus email" > bogus_msg.txt
And then tried to validate it:
$ cat bogus_msg.txt | dkimverify
signature verification failed
$ echo $?
1

Fabric sudo() not respecting env.password

I'm trying to prefill env.password using --initial-password-prompt, but remote is throwing back some strangeness. Let's say that I'm trying to cat a root-owned file as testuser, with 600 permissions on the file. I'm calling sudo('cat /home/testuser/test.txt'), and getting this back:
[testuser#testserver] sudo: cat /home/testuser/test.txt
[testuser#testserver] out: cat: /home/testuser/test.txt: Permission denied
[testuser#testserver] out:
Fatal error: sudo() received nonzero return code 1 while executing!
Requested: cat /home/testuser/test.txt
Executed: sudo -S -p 'sudo password:' -u "testuser" /bin/bash -l -c "cat /home/testuser/test.txt"
Is that piping the prompt right back into the input? I tried using sudo() with pty=False to see if it was an issue with the pseudoterminal, but to no avail.
Here's the weird part: calling run('sudo cat /home/testuser/test.txt') and invoking fab without --initial-password-prompt passes back a password prompt from remote, and on entering the password, everything works fine.
Naturally, running ssh -t testuser#testserver 'sudo cat /home/user/test.txt' prompts for a password and returns the contents of the file correctly. Do I have an issue with my server's shell config, or is the issue with how I'm using sudo()?
Down the line, I'm likely to set up a deploy user with no-password sudo and restricted commands. That'll probably moot the issue, but I'd like to figure this one out if possible. I'm running an Ubuntu 14.10 VPS, in case that's relevant.
Oh, my mistake. I had foolishly set env.sudo_user to my deploy user testuser, thinking that it was specifying the invoking user on remote. In fact, it was specifying the target user, and I was attempting to sudo into myself. Whoops.

Yowsup WhatsApp get phone number

I'm trying to understand how to use the Yowsup library for WhatsApp. I can send message and I can receive it, but I'm interested to get the phone number to start a new chat.
In other words, will develop a computer app that can interact with WhatsApp users, for now I can do the following:
I got the access to WhatsApp server by using this command: python yowsup-cli -c config.example --requestcode sms and python yowsup-cli -c config.example --register xxx-xxx
I send message by using this command: python yowsup-cli -c config.example -s 39xxxxxxxxxx "!"
I can have an interactive conversation by using this command: python yowsup-cli -c config.example -i 39xxxxxxxxxx
Get all message I received by using this command: python yowsup-cli -c config.example -l
Now when an user send me a message how I can interact with him/her? I guess I should get the phone number form the command python yowsup-cli -c config.example -l and begin a new interactive conversation with this command: python yowsup-cli -c config.example -i 39xxxxxxxxxx in which the 39xxxxxxxxxx is the number of the user I get with the previous command.
I hope you can help me
I don't think you want to be using yowsup-cli for development purposes. I think it's intended to be a simple demo client with very limited functionality.
If you look at the yowsup-cli source code you will see it actually imports the included examples to provide the command line message functionality.
What you see inside this code is that your python yowsup-cli -c config.example -l actually calls
wa = WhatsappListenerClient(args['keepalive'], args['autoack'])
wa.login(login, password)
This example listener client on the other hand has a callback function registered to the message_received signal.
self.signalsInterface.registerListener("message_received", self.onMessageReceived)
Now if you take a closer look at this function
def onMessageReceived(self, messageId, jid, messageContent, timestamp, wantsReceipt, pushName, isBroadCast):
formattedDate = datetime.datetime.fromtimestamp(timestamp).strftime('%d-%m-%Y %H:%M')
print("%s [%s]:%s"%(jid, formattedDate, messageContent))
if wantsReceipt and self.sendReceipts:
self.methodsInterface.call("message_ack", (jid, messageId))
You can se that the jid and therefore the phone number which you say you need is on the parameter list of this signal. If you wish to interact with a user after he has sent you a message my guess would be you should store the jid or phone number in your own subscriber to this signal.
In short - don't use the the yowsup-cli per se for development. Use it as a starting point to build your own app. Good luck!

Can't use CNTLM to connect to pip

I'm trying to use Pip behind a proxy server which requires authentication. I've installed cntlm and filled out the hashed passwords. When I run this:
cntlm -c cntlm.ini -I -M http://www.google.co.uk
I enter my password and then get this as a result:
Config profile 1/4... Auth not required (HTTP code: 200)
Config profile 2/4... Auth not required (HTTP code: 200)
Config profile 3/4... Auth not required (HTTP code: 200)
Config profile 4/4... Auth not required (HTTP code: 200)
Your proxy is open, you don't need another proxy.
However, pip doesn't work, still giving me a timeout. Knowing that I don't need another proxy is all fine and dandy, but pip still times out. Port 3128 is working because I can telnet on that port and it shows as listening under netstat. So what should I do from here?
Thank you.
I have had the exact same issue.
Cntlm is used for authentication proxy servers, these statements mean that your server does not require authentication.
The pip command does have a --proxy option. Try using something like:
pip install --proxy=10.0.0.1:80 package_name
If this works, you know that you don't need authentication to access the web. If it still fails try:
pip install --proxy=user:password#10.0.0.1:80 package_name
This works to get around authentication. I have written a small cmd script to get around this in windows:
#echo off
:: GetPwd.cmd - Get password with no echo.
setlocal
<nul: set /p passwd=
for /f "delims=" %%i in ('python -c "from getpass import getpass; pwd = getpass();print pwd;"') do set passwd=%%i
echo.
::Prompt for the package name
set /p package=What package would you like to get:
::Get the package with PIP
pip install --proxy="admin:%passwd%#PROXY_ADDRESS:80" %package%
endlocal

Categories