click package tokens in Python - python

I am working on a command line interface by using the click package in Python. I got struck at getting token as an argument in sub-command. For more details I am attaching an image on how i want the function like in this
As specified in the image I got stuck at that point, so please help me on this issue.

there you dont need any token interface it just a string name
#click.argument('tokens',nargs=-1)
when we use this way we get the output as you mentioned above.

Related

Adding markdown highlighted fenced block to django app with markdonx

I have been looking through the documentation but I can’t seem to get this to work. I wish to publish posts from a “creation page”. I want to use the editor markdownx. I got it to work, however there is no “fenced code support”. I tried to add the following line of code to my settings.py
MARKDOWNX_MARKDOWN_EXTENSIONS = ['fenced_code']
but it breaks the code, in fact I get the following error (when I try to create a post):
SyntaxError at /markdownx/markdownify/
if I erase the extensions list, it works fine.
I would like also to use the codehilite extension by adding it to the list like this
MARKDOWNX_MARKDOWN_EXTENSIONS = ['fenced_code' ,'codehilite']
but it does not work. I have installed pigments but the documentation does not seem to help. Could someone help me add this extensions correctly, getting highlighted code blocks to work. Thank you very much.

gnupg.GPG: Sorry, no terminal at all requested - can't get input

I am trying to encrypt a file using Python GNUPG library and it doesnt work!
Here is my code snippet:
import gnupg
gpg=gnupg.GPG(homedir='/home/datadev/')
recipients=['realname#email.com']
f = open('/home/datadev/filename','rb')
status = gpg.encrypt(f,recipients)
/home/datadev is the folder where I have my .asc file and all .pubring files related to gpg.
After reading the post gpg: Sorry, no terminal at all requested - can't get input
I tried out the following option:
gpg=gnupg.GPG(options='')
but the error is always "gpg: Sorry, no terminal at all requested - can't get input"
It would be helpful if someone could advise me as to what is wrong.
The message about the terminal indicates that there is something wrong, but gnupg cannot tell it as there is no terminal. The python wrapper calls the gnupg executable. Apparently, the gnupg output is not consistent in a way that everything comes back with a return code etc.
So the problem is a different one. I faced the same issue. After passing in the recipients not as a list but just straight it worked. The code documentation of encrypt gives an example for multiple recipients - just pass them as single parameters. Converting list to string would to the trick in the above example.
The correct answer is the PGP/GPG feature needs to be activated in WHM. I had this feature working, then after altering the features for an account's Package as defined in WHM, it stopped working. I went back and noticed this option had been unchecked. Checked it, ran my code again and, success.

How can I send a picture from my computer to my Discord Bot w/ Python

This is my first time posting a help request/question on this website, I've seen that the community is helpful.
I'm a newbie into Python scripting. I currently got a music player's bot template, so I could start learning messing up with the notepad++, and python.
I've seen how you can post the picture, by doing client.send_file(channel,Picture).
I tried just put in picture the file's location(picture), and it said that it wasn't defined.
I tried also let picture, and try create something defining Picture.
def Pic1 'C:\Users\Norberto\Documents\NMusicBot\Pictures\MyPic1.jpg'
It gives me a Syntax error.
SyntaxError: invalid syntax.
Maybe this is simple to solve, but I can't figure out how to fix this!
Regards,
Norby.
I finally fixed it.
The location of the file usually is something like "C:\Users\Something", while writting the location in the script, you need to add the '\' twice, something like: "C:\Users\Something".
For send it, it's just Client.send_file(location).
You can also create a 'shortcut' for it, by doing "Pic1 = C:\Users\Something" and then, "Client.send_file(Pic1).

Dbus.Array (Reading pidgin messages from python)

I am trying to read a message on a pidgin window using python. I have read Pidgin how to and I using the following code:
purple.PurpleGetConversations()
and I get the following output:
dbus.Array([dbus.Int32(14414)], signature=dbus.Signature('i'))
I dont know how to access the elements of this dbus.Array
Best Regards
PD: I am interested in reading the messages, if there is a better way please let me know
Progress update: If anyone else is interested in this, I came up with an alternative solution. Pidgin leaves chat logs in ~/purple, from python you can open this files and use regex to read all msgs.
(If there is a more straigthforward way please tell me)
I found it, Here is the resulting code:
convID = purple.PurpleGetConversations()
msgpos = purple.PurpleConversationGetMessageHistory(convID[0])[0]
print purple.PurpleConversationMessageGetMessage(msgpos)
This will print the last message from an open chat
You need to use PurpleConversationGetChatData method, it takes conversation id as a parameter (14414 in your case).
I have javascript client generated from introspection xml, it might be helpful addition to a dbus documentation - https://github.com/sidorares/node-pidgin/blob/master/index.js

Why doesn't matlab find this function call?

So I downloaded some compiled matlab files. I see the following files in a folder.
makemesh.mexmaci64
makemesh.mexw32
makemesh.mexw64
I added this folder to userpath, and now the path variable shows that this folder exists in it.
I try to run a test script that came with these files, and I get this error message.
Undefined function 'makemesh' for input arguments of type 'struct'.
Now to trouble shoot, I need to find,
Does it find the function, but the data type is wrong.
It doesn't even find the function.
And if it is case 1.
1a. How do I find out what is the proper data structure that function expects.
I am good with python, but new to matlab, so any tips you can add regarding how to query the help string of a function, how to print out the function signature given a function name (like ?function_name in ipython interface) would be super useful.
thank you,
computer('arch') returns glnxa64 which stands for GnuLiNuX 64bit. You have downloaded binaries for Win32bit (mexw32), Win64bit (mexw64) and IOS on Intel (mexmaci64). Either get the source files to compile it yourself or the binaries for linux.
You can find the location of a file on your path by using the which command. For example:
which makemesh.mexw64
should print the location of that file to the terminal. If you get
'makemesh.mexmaci64' not found.
then it means that the file does not exist on your path.
As for finding out what the function wants, I'd start with "help"
help makemesh.mexw64
and see if that gives you anything useful.
I suspect that somehow or other, your matlab is not recognizing the mex file as a function, so I'd start looking there.
You can use the command which <functionName> to see if Matlab is seeing your function.
Have you tried help <functionName> to see if there are any useful comments on what your function is expecting?

Categories