Received data Parsing in Python [closed] - python

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
This is an assignment. So, if what I am asking is something I should figure out myself then lemme know! :)
The thing is that I am to send a complete directory which may have files and sub-folders to the server. To differentiate b/w binary data, filename and folder name. I have assigned specific key letters !,^,| before and after data. (receiving one byte at a time). Though this seems like a hack to what I am trying to do. Is there a better solution?

Compress it with gzip or similar before sending and unpack it after transfer. This will save you the hassle dealing with multiple files.
http://docs.python.org/2/library/archiving.html

If your assignment does not specify a byte-stream, you can also try the SFTP protocol. It's pretty neat with commands like MKDIR, CD, PUT, GET. You can iterate through your file structure, check whether its a folder or a file and appropriately send through commands to the server.
I recommend paramiko - http://www.lag.net/paramiko/

Related

How to save an svg-element using selenium not locally? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a python-selenium-bot that takes a screenshot of an image and saves it in an assets folder which my frontend flutter-app then accesses.
However I think there is a better way to do this. Is it possible to not save the picture on the disk but rather in a variable or something like that so that I can send it via my rest api. This would be a lot cleaner and not so error prone.
Is there any way to save a svg without taking a screenshot of it?
Update:
My solution now is calling driver.get_screenshot_as_bas64 this allows me to save the screenshot as base64 in a variable and then pass that through my API. My Frontend can then decoded that screenshot again.

Should I create a new file for save data with python? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
It may seem like a stupid question, but I really can't find information about this in google.
I am trying to develop a server-client application in python language, I am searching for a correct way to save data on a computer.
I have a client, that when he click the "Register" button I want that his computer will save the information and he can auto-login when he secondly entered the program.
Should I make a new file, save it with the data in the computer and then, load it again and read the data? I really don't know is this is the correct way.
There are different approaches to this problem. You could save the credentials/token/.. to the local disk, but keep in mind that in some cases this might be consindered a security risk. If you do so you should probably store it under user's home folder to keep it from other (non-admin/root users) at least.
You could also store it and encrypt it with e "Master password" (like Firefox does if you enable it).
Or you could connect to a 3rd party authentication server and store your information there. It all depends on the use case you are implementing as well as the complexity required.

Find all files in a directory on another server in python [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'd like to be able to list all files found in a directory tree on a server that requires authorization for access. If I were trying to list files within a local directory tree, I would use the os.walk functionality (quite simple, I like that); however, when I'm trying to search a secure server, I'm lost. I know the credentials to log onto that server, but I'm not sure of the steps needed to log in and retrieve the information above (I'm new to python). Can anyone provide examples? Thanks.

Python R/W to text file network [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
What could happen if multiple users run the same copies of python script which designed to R/W data to a single text file store in network device at the same time?
Will the processes stop working?
If so, what could be the solution?
It can happen many bad things, I don't think the processes stop working, not at least because of concurrent access to file a file, but what could happen is and inconsistent file creation: for example, if one processes write hello, and there is a concurrent access to the file, you might get a line like hhelllolo
A solution I can see is, use a database as suggested, or, create a mechanism for locking the file to concurrent accesses (which might be cumbersome because you're working on network, not the same computer)
Another solution I can think of is create a server side simple script who handle the requests and lock the file for concurrent access. This is almost the same solution as using a database, you'll be creating an storage system from scratch so why bother :)
Hope this helps!

parsing C code using python [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have a huge C file (~100k lines) which I need to be able to parse. Mainly I need to be able to get details about individual fields of every structure (like field name and type for every field in the structure) from its definition. Is there a good(open source, which i can use in my code) way to do this already? Or should I write my own parser for this. If I have to write my own, can anyone suggest a good place to start? I have never worked with python before.
Thanks
Take a look at this link for an extensive list of parsing tools available for Python. Specifically, for parsing c code, try the pycparser
The right way to do this is almost certainly to interface with the front-end of an existing compiler, such as gcc, then work with the intermediate representation, rather than attempting to create your own parser, in any language.
However, pycparser, as suggested by Dhara might well be a good substitute, and definitely better than any attempt to roll your own.

Categories

Resources