SFTP with python [closed] - python

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 1 year ago.
Improve this question
Does anybody know of a methodology to get a remote file from a server using a python script, that will work suitably well for very large files?
I'm currently using Paramiko, and it works quite well, however i'm concerned that the target use case for this will be .bag files of considerable size, potentially around 10 gig. My limited understanding of this is that the downloaded file will be stored in RAM rather than on the drive, until I store it onto the drive.
Or am I loking at optimising a problem that doesn't exist?
Is there a way to save the data as it is being downloaded?
I had thought about just using a bash script, which i suppose would work, but there's a lot of additional functionality that is required. Hence my use of python.
Another option would be to use OS library to simply run SFTP.
I'd appreciate anyones thoughts on this.
Thanks!

It would seem my understanding of Paramiko and SCP / SFTP was flawed.
The default way to do it, does not store it in RAM, and i'd misread code that I'd written last year - we're all guilty of that!
A minimum working example -
def DownloadSFTP(self):
self.sftp.get(self.remotepath, self.localpath)
self.sftp.close()

Related

How to make a self running file? [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 2 years ago.
Improve this question
I have a activity in school about how a hacker might hack your pc without knowing, I was assigned to make a self running file, what I'm trying to do is, when a person for eg. Downloads a file, then without he opening it should already run without even the user opening it. Is this possible?
This is not possible, not really actually.
If you want a file to be executed without the user executing it first after download, you will have to do one of such things:
Have an already running program on his machine that looks for your file and then executes it when he finds it in the downloads (MAGIC in the beginning of the file for example or hash validation).
Take advantage of a poorly protected software that executes other files or codes (Or override a standard library) file and make it run your code instead. of course this is not as simple as it sounds and requires you to understand the software that you are attacking pretty good.
Note: Most programs won't just execute some arbitrary code and probably wont just use execv for no reason or without making sure that everything is correct and protected, which makes that solution (Without finding a security breach in the software) pretty difficult.

How to communicate between two computers in 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 3 years ago.
Improve this question
I am attempting to make a python a "buzzer" application which will function like the buzzers in jeopardy. It will (hopefully) work by linking several computers to a main computer. When a user taps the screen of their computer, if they are the first, it will change the color of their screen and alert the main computer. Now for my question: when module would be best to like together these two computer. I would need to send the name of the computer and a timestamp and the main computer would need to respond. I was reading that something like socket might work, but i am unsure. Also, could you please give me a link to documentation on whatever module you suggest. Thanks!
You mentioned socket in your question.
https://docs.python.org/3/library/socket.html
This might be appropriate for your needs, however with multiple clients it can get quite complicated.
Also, you may want to try using email for easier connections (if you don't mind the send time of a few seconds). I know it sounds stupid, but it has worked for me in the past, with significantly less difficulty than a multi-threaded socket connection.
https://docs.python.org/3/library/email.html
https://docs.python.org/3/library/smtplib.html

Manipulating a specific bit on the Hard Drive [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 6 years ago.
Improve this question
I've recently started looking into low level bit manipulation.
http://bits.stephan-brumme.com/
and
http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetNaive
I understand the concept of how to clear/set/toggle/check etc., a bit within an integer or a byte. (Get a specific bit from byte)
I cannot however seem to find how to change the value of a bit at a specific location in my hard drive.
I would be attempting to do this in Ubuntu 14.04 LTS. I am most familiar with Python and C++ but i'll take answers in any language.
It would go like this:
Open the drive for read/write, as root. (ex: /dev/sda)
Mmap the drive (or you can seek and read/write)
find the byte, modify the bits you want, flush and unmmap (or close).
Someone else would probably provide the code version of this.

Running a python script using several computers (grid/cluster) [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
Is there a way to run my python script using several computers communicating through my web server? Willing to do a lot more research if someone can point me in the right direction, but I can't seem to find any useful info on this.
A simple script can't be automatically distributed, you need to break it into components that can run independently when given a part of the problem. These components run based on commands received from a library like PyMPI, or pull them from a queuing system like http://aws.amazon.com/sqs/
This also means you can't rely on having shared local memory. Any data that needs to be exchanged must be exchanged as part of the command, stored on a shared file system or placed in a database AWS Dynamo, Redis, ect.
There are a large number of links to more resources available at https://wiki.python.org/moin/ParallelProcessing under the Cluster Computing heading.

python how to -generate license- using time module [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 7 years ago.
Improve this question
I'm searching for a way to generate a (limited time license) .so
when a user starts the program . it has to check license date first before the program runs.
but the problem is :
i tried a couple of solutions . one of them is python's time.ctime , (to check time and see if it's realy during the license time) and it returns the time of the machine, so whenever a user want to use software without license he'll just change time of the machine.
i hope the idea is clear enough
any better ideas?
please inform me if you want more explanation
Regardless with the question whether or not this hassle is really worth the effort, you can check access times of ubiquitous files (e.g. /etc/passwd in Linux) and compare these to the current date. If you see that the files have been accessed/modified in the future, you know that there is a problem. Again, at least in *nix, a user may substitute system's stat, so that it "massages" the info you are looking at.
You could get the time from an external source via Internet: Python Getting date online?
Of course, this will only work if the user doesn't block your program from accessing the internet. And what should your program do when it can't access the internet? Refuse to run? I doubt that this is a good idea.
Nearly every standard function will return the machine time that can be adjusted by the user.
One possibility is to call a web service that returns the "correct" time. But this is only possible if you can assume internet access.
And may be should ask your self the question if that hassle is really worth the effort?

Categories