I'm trying to do a phone call by python script from skype account. It runs properly sometime while sometime give segmentation error while sometime it runs without error but no output. I had used following script for this as,
import Skype4Py
import sys
skype = Skype4Py.Skype()
skype.Attach()
m_PhoneNumber = "919763667993"
m_Call = skype.PlaceCall(m_PhoneNumber)
Please give me solution for this, i think it maybe Skype4Py.api.posix_dbus.SkypeAPI Thread Problem ,
but not getting solution for this.
Related
I have a bot that works in a discord server for a minecraft server.
I want to make one of the bot's command to ping the minecraft server to check if it is up (or even get stats like number of players).
Does anybody know of a way to ping a mc server and even get stats from said server?
This is possible! You can use Dinnerbone's own implementation.
This basic Python script should do what you want (using hypixel as an example):
from mcstatus import MinecraftServer
server = MinecraftServer.lookup("mc.hypixel.net")
status = server.status()
print("The server has {0} players and replied in {1} ms".format(status.players.online, status.latency))
latency = server.ping()
print("The server replied in {0} ms".format(latency))
There's heaps more you can do, check it out: https://github.com/Dinnerbone/mcstatus
You can install this package by running:
python3 -m pip install mcstatus
Also note that according to the Github repo, this will only work on servers above version 1.7 :)
You can do that with SourceQuery - pick the code from github and you can import that in your DC Bot and it gives you all the information any GoldSRC Server can give you, MC works with it as well.
https://github.com/olli-e/ISRT-Insurgency-Sandstorm-RCON-Query-Tool/blob/main/bin/SourceQuery.py
You will find an example usage at the end of the script.
You can also use mcrcon, but I assume you want to wrap it in python.
I want to send windows notification about some important message via python. I have tried win10Toast, but notifications disappear after program is finished.
My code is:
## program to generate a simple toast notifier
from win10toast import ToastNotifier
## instantiating the class
n = ToastNotifier()
n.show_toast("Test Message","Notification body",duration=15)`
It runs fine as long as my program is running, but it disappears after the program is finished. I want to show this message in system tray until user discards this message.
Secondly can you please tell me how to see notification history?
I am using Python 3.7 and Windows 10
change "duration=15" for 'duration=None
I'm currently working on a little script that I found on GitHub, made by RoGeorge : https://github.com/RoGeorge/DS1054Z_screen_capture.
This script should allows me to get a screenshot of my digital storage oscilloscope (DS1054z from RIGOL).
So I've putted this script on my Raspberry Pi to have use it, but once everything was correctly setup, the script seems to receive nothing from my scope. This is surprising because : I can ping the scope and I can communicate with him by the telnet command on the terminal.
So I've made a little script (that I will put just below) that permit me to see if the Telnet library for Python work or not.
Result : It do not work when we went to read, but it's send without problem.
import telnetlib
tn = telnetlib.Telnet('193.168.1.2','5555')
tn.set_debuglevel(100)
tn.write("*idn?")
tn.read_until('\n',1)
Output :
>> Telnet(193.168.1.2,5555): send '*idn?'
>> ''
Is my code correct ? Did anyone have an idea of what is happening ?
Thanks in advance !
PS : I've tested the script from GitHub and mine just above on my Windows 10 PC also. Don't work.
When you send a command you have to end it with a newline like this:
tn.write("*idn?\n")
I wrote a python script that uses win32com.client.Dispatch("Outlook.Application") to send automated emails through outlook.
If I run the script myself everything works perfectly fine. But if I run it through Window's task scheduler it doesn't send the emails.
Just to check if I am running the script properly I made the script output a random text file and that works but email doesn't. Why?
Do you add any attachments to an email before you send it? I had a similar problem but it is working perfectly now. If I had two different functions in my script to send emails (for example one to send an email in the event of an error, and one to send an email if the script ran successfully) I would get an 'operation aborted' error from Outlook. This was because in one of the functions I would add an attachment to the email, however in the other function I wouldn't. Don't ask me why but this would cause an error. To resolve I just had to add a redundant attachment to the email that didn't need an attachment.
def emailComplete():
ol = DispatchEx("Outlook.Application")
Msg = ol.CreateItem(0)
Msg.To = "recip#ient.com"
Msg.Subject = "foo complete"
Msg.Attachments.Add("C:\Path\to\blank\attachment.txt") # send a blank attachment to stop the 'operation aborted' error
Msg.Send()
ol.Quit()
def emailError():
ol = DispatchEx("Outlook.Application")
Msg = ol.CreateItem(0)
Msg.To = "recip#ient.com"
Msg.Subject = "foo errored"
Msg.Attachments.Add("C:\path\to\error\file.txt") # send the error file with the email
Msg.Send()
ol.Quit()
It's not the most elegant solution, but it's got mine working!!
My similar issue has been cleared up. I used task scheduler to call a python script (via batch file) that has the pywin32com module. The python code opens excel and calls a macro. It will run fine from python, cmd and the batch file, but wasn't working when ran through task scheduler. It traced back to errors like:
"EnsureDispatch disp = win32com.client.Dispatch(prog_id)"
As noted on this thread, I changed the option to "Run only when user is logged on" and it ran successfully!
The only drawback is that I schedule the task for a time that I'm away from the computer. I suppose I just have to not log off and hope that the cpu doesn't go into sleep mode, but that's not really a big deal in this case.
I had the same issue with an Excel application I built. When executed during my trouble-shooting I would get an Outlook profile dialog box that I couldn't circumvent. Oddly enough, this dialog box wouldn't appear during scheduled execution. I found a way around this and that was to send email using CDO. I understand that you're not using VBA but this could point you to an alternate method of sending an email (like what I had to do):
http://www.rondebruin.nl/win/s1/cdo.htm
Note: I was only able to have success when I set the Security Option to "Run only when user is logged on" (I have full admin rights on my machine and am running w/highest privileges). I have a strong -- but unconfirmed -- suspicion that there is some security setting invoked when the Task Scheduler is involved, at least in a corporate environment.
I am having trouble with getting Skype4Py to attach to my Skype client. I downloaded easy _install and used it to install Skype4Py. I have 64bit Python and windows 7. When I try the example script (seen below) line by line using the IDLE, I can't get past the skype.attach(), nothing seems to happen. I end up having to close the IDLE and kill the application. If you have any ideas please let me know. I apologize in advance. Just figuring out how to download Skype4Py was challenging for me. Skype is running and I am logged in.
import Skype4Py
# Create an instance of the Skype class.
skype = Skype4Py.Skype()
# Connect the Skype object to the Skype client.
skype.Attach()
# Obtain some information from the client and print it out.
print 'Your full name:', skype.CurrentUser.FullName
print 'Your contacts:'
for user in skype.Friends:
print ' ', user.FullName
Currently looks like 64-bit Python is not supported, because Skype the client application is 32-bit.
https://github.com/awahlig/skype4py/issues/6
Use 32-bit Python.