Re: [Tutor] Borrowing free code

2018-12-04 Thread Steven D'Aprano
On Tue, Dec 04, 2018 at 11:43:05PM +, Alan Gauld via Tutor wrote:
> On 04/12/2018 19:31, Avi Gross wrote:
> 
> > But some packages are simply python code that you can 
> > simply insert into your own python files. 
> 
> If they are fully public domain that's probably true.

Almost nothing younger than 70 years is in the public domain. Nearly all 
countries share certain copyright laws, including automatic granting of 
copyright for the life of the author + many years (exactly how many 
depends on the country) whether you want it or not.

According the lawyers behind the Creative Commons, many jurisdictions 
make it difficult if not impossible to voluntarily give up copyright and 
put a work in the public domain:

https://creativecommons.org/share-your-work/public-domain/cc0/

One of the few exceptions is that many (but not all) works by the US 
government are required to be placed in the public domain by law.

Having said that, all is not *quite* lost (yet). There are still ways to 
get equivalent freedom as if the work was in the public domain, and 
another Mickey Mouse Copyright Extension Act is unlikely to occur any 
time soon.


> If they are copyright (even if open/free) you would be
> potentially liable for prosecution since you are copying
> someone else's work.

That's a rather negative way of looking at it.

Copyright infringement is typically handled through the civil courts: 
the legal authorities don't press charges for copying (except, perhaps, 
in the case of large-scale piracy of manufactured goods like fake 
designer handbags, movie DVDs, etc). Rather, the copyright owner has to 
sue you. If the copyright owner is explicitly giving you the right to 
copy and modify the software, which is the case for FOSS (Free Open 
Source Software), then you have nothing to fear so long as you have a 
valid licence.

If you have a valid licence to use and copy the software, and you obey 
the licence terms, then you are in no danger of being prosecuted for 
copyright infringement because you are licenced to do so.


> Even if it is open source then at the very least
> you should include a comment to the effect that
> the code is based on, say, M Palin's file parrot.py
> or whatever.

Giving credit might be good from an ethical point of view, but it may 
not be either necessary or sufficient (depending on the licence).

Some examples: 

The MIT and BSD licences do not explicitly require you to credit the 
author, but they do require you to include a copy of the original 
author's copyright and licence in your work:

https://en.wikipedia.org/wiki/BSD_licenses
https://en.wikipedia.org/wiki/MIT_License

If you choose to give credit as a courtesy, that's fine, but you must be 
careful as to do so in such a way that you avoid giving the impression 
that the author endorses or is responsible for your work.

Good: "MyApp, by me, with a big thank you to J. Cleese for 
his spam library."

Bad: "MyApp with spam by J. Cleese!"


On the other hand, the GPL requires more than just credit, it requires 
that (with some exceptions, including fair use) if you duplicate their 
code, that your code in turn must be released under the GPL as well. 
Merely giving credit is in no way sufficient.

And on the gripping hand, you have ultra-permissive public-domain like 
licences such as the creative commons CC0 or the Toybox licence:

https://en.wikipedia.org/wiki/Public-domain-equivalent_license

neither of which require credit be given.

Regardless of the licence, you must obey the conditions (whether they 
are minimal, as in the MIT licence, or onerous and difficult as in most 
proprietary licences) in order to be legally permitted to copy the work. 
But if you have a licence to copy, then of course you may copy according 
to the terms of the licence.

In a practical sense, copying trivial amounts of code from software 
licenced under the MIT licence, or similar, would be highly unlikely to 
get you sued. For starters, the author would have to know you copied it, 
and care, and track you down in real life, and sue you. And if the code 
snippet was small enough, you could defend on the basis of fair use.

(Although more and more jurisdictions are taking a hard-line, minimalist 
approach to fair use, allowing it effectively only for the purposes of 
satire. Or even not acknowledging a fair use right at all.)

Another factor may be that, regardless of the *actual* legal risk, some 
employers may not allow copying or use of (some or all) FOSS software 
even if licenced, because they may fear the unknown, or they believe 
anti-GPL propoganda ("its a virus that means you will have to give up 
your intellectual property"), ethical reasons (copying without 
attribution may be plagiarism), or possibly even for legitimate legal 
reasons ("the GPL is not compatible with our licence").

Bottom line: yes, you can legally copy FOSS software, under certain 
conditions, and need not fear being prosecuted.

(Actually, you could 

Re: [Tutor] Borrowing free code

2018-12-04 Thread David Rock

> On Dec 4, 2018, at 13:31, Avi Gross  wrote:
> 
> David,
> 
> What does it mean when someone says they cannot install a module? I can see 
> how a school assignment might require using only some limited set of 
> functionality. I note some installations add more than others or let you 
> designate optional components to include.

In the context of what the OP posted, I don’t think it actually matters if they 
mean “not allowed,” “not internet accessible,” or something else.  The 
statement is enough to move on in the conversation to try and be productive 
rather than belabor the point.

That said, hopefully we will get some feedback on the OS and ssh setup options.

— 
David Rock
da...@graniteweb.com




___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Borrowing free code

2018-12-04 Thread Alan Gauld via Tutor
On 04/12/2018 19:31, Avi Gross wrote:

> But some packages are simply python code that you can 
> simply insert into your own python files. 

If they are fully public domain that's probably true.
If they are copyright (even if open/free) you would be
potentially liable for prosecution since you are copying
someone else's work.

Even if it is open source then at the very least
you should include a comment to the effect that
the code is based on, say, M Palin's file parrot.py
or whatever.

> And, yes, this means you do not get updates if the module changes.  

And this is a big drawback for any non trivial code
unless you are a significantly better programmer
than whoever wrote it in the first place. (Since
understanding somebody else's code is much harder
than understanding your own!)

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Borrowing free code

2018-12-04 Thread Avi Gross

David,

What does it mean when someone says they cannot install a module? I can see how 
a school assignment might require using only some limited set of functionality. 
I note some installations add more than others or let you designate optional 
components to include.

Some companies may have security concerns or portability considerations. The 
finished product may be used on machines lacking what is needed or even cut off 
from the ability to get them.

But some packages are simply python code that you can simply insert into your 
own python files. If they have few external dependencies and no need to compile 
C code, can you copy them without violating rules?

I am thinking for example of a module that defines a class you may want to 
subclass. You could find the source code you would have imported and take 
relevant parts into your main code file or into any local files you import. 

I do not know if the module being discussed meets the criteria or if this would 
not  be considered honest. But it is a step to be considered. Another thread I 
have seen related to a user with no internet connection for downloading. But 
sneakernet is trivial if the only thing needed for an install might be copying 
a file or three into any valid location on the machine including the directory 
your main program is in.

And, yes, this means you do not get updates if the module changes.  

Just a thought.


Sent from AOL Mobile Mail
On Tuesday, December 4, 2018 David Rock  wrote:

> On Dec 4, 2018, at 12:05, Asad  wrote:
> 
> Hi All ,
> 
>          I am not allowed to import pexcept  .Therefore only option I
> have is to implement a solution using the standard libraries in python .

I’m only suggesting it because it’s an easier way to interface with expect.  If 
you aren’t allowed to install it, then we’ll stop talking about it.

>            However I am using subprocess.Popen for sftp I am unable to
> pass the password.
> 

You still are not understanding my point.  using sftp in batch mode CAN’T USE a 
password.  If you look at the manpage for sftp, batch mode prohibits it.

    -b batchfile
            Batch mode reads a series of commands from an input batchfile 
instead of stdin.
            Since it lacks user interaction it should be used in conjunction 
with non-inter‐
            active authentication.  <<—

“non-interactive authentication” means you must use an ssh key to authenticate 
instead of a password.  In other words, trying to figure out how to send a 
login to the subprocess is not the issue; even if you can, it won’t work 
because sftp *in batch mode* will not accept it.  If you _can’t_ set up an ssh 
key for this access, then you MUST stop trying to use batch mode, because it 
will never work.

>  Here I am unable to proceed , I am sure someone would have cracked this
> problem earlier if they can share the code

There is no code for this because it is not possible to do within the 
constraints you have proposed up to this point.

1. Can you set up ssh key passwordless authentication?
  if yes, then do it and what you have now will start working
  if no, then you can’t use sftp the way you are currently trying (the -b 
“batch mode”) and find a different solution (expect, here docs, etc).


— 
David Rock
da...@graniteweb.com




___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Beginners Book, Python and PyScripter

2018-12-04 Thread Adam Eyring
I haven't gone through many python books, but have been using a copy of
Automating the Boring Stuff with Python. It covers lists, dictionaries,
scraping data from websites, etc.
https://automatetheboringstuff.com/
The PDF is free.

Adam

On Tue, Dec 4, 2018 at 1:09 PM James Stapleton-Cotton 
wrote:

> Thank you Mats and Steven. I'm back on track now with a different tutorial
> which has lead to me to the relevant coding tools.
> https://wiki.python.org/moin/BeginnersGuide/NonProgrammers
> https://python.swaroopch.com
>
> On Mon, Dec 3, 2018 at 4:04 PM Mats Wichmann  wrote:
>
> > On 12/3/18 3:35 AM, James Stapleton-Cotton wrote:
> > > Hello,
> > >
> > > On this page (
> > >
> >
> http://openbookproject.net/thinkcs/python/english3e/way_of_the_program.html
> > )
> > > - a book for learning Computer Science using Python - I am directed to
> (
> > > http://code.google.com/p/pyscripter) in order to access the
> appropriate
> > > program development environment, PyScripter. I have downloaded the
> latest
> > > version of Python from Python.org and PyScripter from a site that I am
> > > directed to from the original site mentioned in the beginning of this
> > email
> > > - (https://sourceforge.net/projects/pyscripter/files/), however I
> can't
> > > seem to be able to run PyScripter on my Mac.
> >
> > it looks like from the project's own description that PyScripter is
> > intended solely for the Windows environment.
> >
> > But there are a TON of other IDE products, free and commercial, out
> > there, many of which do run on the Mac.
> >
> > This may be information overload, but try looking here:
> >
> > https://wiki.python.org/moin/IntegratedDevelopmentEnvironments
> >
> >
> > ___
> > Tutor maillist  -  Tutor@python.org
> > To unsubscribe or change subscription options:
> > https://mail.python.org/mailman/listinfo/tutor
> >
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] sftp using subprocess

2018-12-04 Thread Mats Wichmann
On 12/4/18 2:44 PM, David Rock wrote:
> 
>> On Dec 4, 2018, at 15:37, Alan Gauld via Tutor  wrote:
>>
>> On 04/12/2018 18:30, David Rock wrote:
>>> you MUST stop trying to use batch mode, because it will never work.
>>
>> But you could presumably use interactive mode via Popen
>> by taking control of the stdin/out pipes.
>>
>> But then you are basically re writing expect!
> 
> Right.  and what’s worse, sftp doesn’t like here documents (by design, for 
> fairly obvious reasons).  The best option (if it’s possible) really is 
> setting up ssh key authentication.

yes, programs which need to prompt for a secret are intentionally
paranoid and hard to work with programmatically. often they flush the
input stream before prompting, so you have to synchronize things across
your pipe to get it to work. it's certainly a reason a program like
expect is non-trivial. you're really better off not trying to reinvent
this logic, as experts have spent a lot of time getting it to work
safely and correctly.

"I am sure someone would have cracked this problem earlier if they can
share the code".  Yup.  The problem is you're telling us you're not
allowed to use the solutions that exist - I presume if pexpect is out,
then other things will be as well?

Here's a project you could look at, though I'm expecting you can't use
it either...

https://bitbucket.org/dundeemt/pysftp/overview


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] sftp using subprocess

2018-12-04 Thread David Rock

> On Dec 4, 2018, at 15:37, Alan Gauld via Tutor  wrote:
> 
> On 04/12/2018 18:30, David Rock wrote:
>> you MUST stop trying to use batch mode, because it will never work.
> 
> But you could presumably use interactive mode via Popen
> by taking control of the stdin/out pipes.
> 
> But then you are basically re writing expect!

Right.  and what’s worse, sftp doesn’t like here documents (by design, for 
fairly obvious reasons).  The best option (if it’s possible) really is setting 
up ssh key authentication.



— 
David Rock
da...@graniteweb.com




___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] sftp using subprocess

2018-12-04 Thread Alan Gauld via Tutor
On 04/12/2018 18:30, David Rock wrote:
> you MUST stop trying to use batch mode, because it will never work.

But you could presumably use interactive mode via Popen
by taking control of the stdin/out pipes.

But then you are basically re writing expect!

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] sftp using subprocess

2018-12-04 Thread David Rock

> On Dec 4, 2018, at 12:05, Asad  wrote:
> 
> Hi All ,
> 
>   I am not allowed to import pexcept   .Therefore only option I
> have is to implement a solution using the standard libraries in python .

I’m only suggesting it because it’s an easier way to interface with expect.  If 
you aren’t allowed to install it, then we’ll stop talking about it.

>However I am using subprocess.Popen for sftp I am unable to
> pass the password.
> 

You still are not understanding my point.  using sftp in batch mode CAN’T USE a 
password.  If you look at the manpage for sftp, batch mode prohibits it.

 -b batchfile
 Batch mode reads a series of commands from an input batchfile 
instead of stdin.
 Since it lacks user interaction it should be used in conjunction 
with non-inter‐
 active authentication.   <<—

“non-interactive authentication” means you must use an ssh key to authenticate 
instead of a password.  In other words, trying to figure out how to send a 
login to the subprocess is not the issue; even if you can, it won’t work 
because sftp *in batch mode* will not accept it.  If you _can’t_ set up an ssh 
key for this access, then you MUST stop trying to use batch mode, because it 
will never work.

>  Here I am unable to proceed , I am sure someone would have cracked this
> problem earlier if they can share the code

There is no code for this because it is not possible to do within the 
constraints you have proposed up to this point.

1. Can you set up ssh key passwordless authentication?
   if yes, then do it and what you have now will start working
   if no, then you can’t use sftp the way you are currently trying (the -b 
“batch mode”) and find a different solution (expect, here docs, etc).


— 
David Rock
da...@graniteweb.com




___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Beginners Book, Python and PyScripter

2018-12-04 Thread James Stapleton-Cotton
Thank you Mats and Steven. I'm back on track now with a different tutorial
which has lead to me to the relevant coding tools.
https://wiki.python.org/moin/BeginnersGuide/NonProgrammers
https://python.swaroopch.com

On Mon, Dec 3, 2018 at 4:04 PM Mats Wichmann  wrote:

> On 12/3/18 3:35 AM, James Stapleton-Cotton wrote:
> > Hello,
> >
> > On this page (
> >
> http://openbookproject.net/thinkcs/python/english3e/way_of_the_program.html
> )
> > - a book for learning Computer Science using Python - I am directed to (
> > http://code.google.com/p/pyscripter) in order to access the appropriate
> > program development environment, PyScripter. I have downloaded the latest
> > version of Python from Python.org and PyScripter from a site that I am
> > directed to from the original site mentioned in the beginning of this
> email
> > - (https://sourceforge.net/projects/pyscripter/files/), however I can't
> > seem to be able to run PyScripter on my Mac.
>
> it looks like from the project's own description that PyScripter is
> intended solely for the Windows environment.
>
> But there are a TON of other IDE products, free and commercial, out
> there, many of which do run on the Mac.
>
> This may be information overload, but try looking here:
>
> https://wiki.python.org/moin/IntegratedDevelopmentEnvironments
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] sftp using subprocess

2018-12-04 Thread Asad
Hi All ,

   I am not allowed to import pexcept   .Therefore only option I
have is to implement a solution using the standard libraries in python .

However I am using subprocess.Popen for sftp I am unable to
pass the password.

I tried the following :

>>> import subprocess
>>> subprocess.Popen(['sftp','usern...@server.com', 'stop'],
stdin=PIPE).communicate(input='abc')


Enter password for username
Password:

  Here I am unable to proceed , I am sure someone would have cracked this
problem earlier if they can share the code

Thanks in advance,   .

On Tue, Dec 4, 2018 at 10:30 PM  wrote:

> Send Tutor mailing list submissions to
> tutor@python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://mail.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
> tutor-requ...@python.org
>
> You can reach the person managing the list at
> tutor-ow...@python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
> Today's Topics:
>
>1. Re: sftp using subprocess (Alan Gauld)
>
>
>
> -- Forwarded message --
> From: Alan Gauld 
> To: tutor@python.org
> Cc:
> Bcc:
> Date: Tue, 4 Dec 2018 08:41:03 +
> Subject: Re: [Tutor] sftp using subprocess
> On 04/12/2018 06:25, Asad wrote:
>
> > Permission denied (keyboard-interactive,publickey,password).
> > Connection closed
> >
> > Is there any other way to acheive this because I cannot import pexcept
> > module .
>
> That looks like the problem that David already highlighted
> with sftp.
>
> When you say you cannot import pexpect, is that because
> you are not allowed to? Or because of some technical issue?
> If so what? We might be able to help fix that.
>
> Also, you do realize that pexpect is not part of the
> standard library? You need to install it first.
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> https://mail.python.org/mailman/listinfo/tutor
>


-- 
Asad Hasan
+91 9582111698
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] sftp using subprocess

2018-12-04 Thread David Rock

> On Dec 4, 2018, at 02:41, Alan Gauld via Tutor  wrote:
> 
> On 04/12/2018 06:25, Asad wrote:
> 
>> Permission denied (keyboard-interactive,publickey,password).
>> Connection closed
>> 
>> Is there any other way to acheive this because I cannot import pexcept
>> module .
> 
> That looks like the problem that David already highlighted
> with sftp.

Yup.  So, back to my other question regarding ssh key access…

Do you have the ability to ssh to an account on the target system (i.e., use 
ssh to log in, not use sftp to grab a file)?
If you do, then the “easiest” solution is to create an ssh key and set up 
passwordless authentication.  If you do not, then maybe you can upload the key 
through some web service.  What is the actual target system to which you are 
trying to connect?  Is there an admin that can help configure ssh key-based 
access for you?

If you can’t set up key access, then you will need to automate sending the 
login information (hence the pexpect recommendation, since this is a python 
list, after all).  If you can’t install pexpect, you may have expect available 
(on what OS are you running your script?); but writing an expect script is 
starting to drift away from a python tutor list a bit.

If you are on linux, you may want to forego python altogether if you can’t get 
the ssh key access enabled and use a bash here document for automation.  
http://www.tldp.org/LDP/abs/html/here-docs.html

The disadvantage to this (and to using expect, for that matter) is plaintext 
storage of credentials on your system, but it’s pretty simple to use.


— 
David Rock
da...@graniteweb.com




___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] sftp using subprocess

2018-12-04 Thread Alan Gauld via Tutor
On 04/12/2018 06:25, Asad wrote:

> Permission denied (keyboard-interactive,publickey,password).
> Connection closed
> 
> Is there any other way to acheive this because I cannot import pexcept
> module .

That looks like the problem that David already highlighted
with sftp.

When you say you cannot import pexpect, is that because
you are not allowed to? Or because of some technical issue?
If so what? We might be able to help fix that.

Also, you do realize that pexpect is not part of the
standard library? You need to install it first.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Regarding Python api script

2018-12-04 Thread Alan Gauld via Tutor
On 04/12/2018 01:31, Ravi Kumar wrote:
> My output api calls in python is in xml so I want the output to be in the
> database

I'm still not 100% clear but I think you are saying
that your API currently returns XML when you call it
from Python. And you want to extract the data from
the XML and store it in a SQL Server database.
Is that correct?

If so the sequence of events is:

1) Connect to web site and retrieve the data (It
   sounds like you can already do this bit)
2) Parse the XML into usable data - you need
   etree (or another parser) to do that
3) Store the data in the database. You need
   a DBAPI module to do that. You will need
   to know some SQL.

Also, for step 3 you will need to either create
a new database or use an existing one. Do you
already have a target database? Or do you need
to design and create the table(s)? That may
require more SQL.

> So is there a way where I can alter my code to get
> api responses in json format in python and then
> later move the output to  the database

The answer to that lies in the API.
Assuming it is not under your control then you need
to read the API documentation to see if there is an
option to change the output to JSON. If not you are
stuck with whatever the API gives you.

Before we can give you any more help you will need
to share some code with us. What have you got
so far?

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] sftp using subprocess

2018-12-04 Thread Asad
Hi All,

I get the following error :

>>> sftp_process = subprocess.Popen(['sftp', '-b', 'batch.txt', user_host],
shell=False)
>>>

Permission denied (keyboard-interactive,publickey,password).
Connection closed

Is there any other way to acheive this because I cannot import pexcept
module .

Thanks,


>
>
> -- Forwarded message --
> From: David Rock 
> To: Tutor Python 
> Cc:
> Bcc:
> Date: Mon, 3 Dec 2018 18:12:05 -0600
> Subject: Re: [Tutor] sftp using subprocess
>
> > On Dec 3, 2018, at 16:01, Asad  wrote:
> >
> > Hi All ,
> >
> >I am looking for a solution to automate downloading file using
> sftp
> > process using :
> >
> > batch.txt :contains the following two lines
> > cd 12345678
> > get 12345678_1.zip
> >
> >
> > import subprocess
> > host="abc.com"
> > user="sa"
> > user_host="%s@%s" % (user, host)
> > sftp_process = subprocess.Popen(['sftp', '-b', 'batch.txt', user_host],
> > shell=False)
> >
> > however it gives error even unable to provide password .
>
> batch mode for sftp assumes you don’t need a password.  From the manage:
>
>  -b batchfile
>  Batch mode reads a series of commands from an input batchfile
> instead of stdin.
>  Since it lacks user interaction it should be used in
> conjunction with non-inter‐
>  active authentication.
>
> You would need to set up an ssh key with a null passphrase, or set up an
> ssh-agent in order for that to work.
>
> Another option would be to use pexpect to automate console input
>
>
> —
> David Rock
> da...@graniteweb.com
>
>
>
>
>
>
>
>
> -- Forwarded message --
> From: "Steven D'Aprano" 
> To: tutor@python.org
> Cc:
> Bcc:
> Date: Tue, 4 Dec 2018 11:12:56 +1100
> Subject: Re: [Tutor] sftp using subprocess
> On Tue, Dec 04, 2018 at 03:31:53AM +0530, Asad wrote:
>
> > however it gives error even unable to provide password .
>
> Is the error a secret? Would you like us to guess what it is?
>
>
> --
> Steve
>
> ___
> Tutor maillist  -  Tutor@python.org
> https://mail.python.org/mailman/listinfo/tutor
>


-- 
Asad Hasan
+91 9582111698
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Regarding Python api script

2018-12-04 Thread Ravi Kumar
My output api calls in python is in xml so I want the output to be in the
database

So is there a way where I can alter my code to get api responses in json
format in python and then later   move the output   to  the database

Basically at the end of it I want the all the data to be in database

Thanks
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Regarding Python api script

2018-12-04 Thread Alan Gauld via Tutor
CCd the list, please use Reply All when responding to the tutor list.

On 04/12/2018 00:52, Ravi Kumar wrote:
> Thanks a lot! I was wondering is it easier to access JSON format into
> Sql Server from python rather than XML If so how do I format my output
> from xml to Json 
>
JSON is generally easier than XML using the json module.


However, I confess I don't know what you mean by

"...access JSON format into Sql Server from python..."

Is the JSON/XML put into the database before you access it?

Or are you trying to access data from JSON/XML and then
store it in the database?

Or are you just trying to store JSON/XML directly into the database?

I really don't understand what it is you are trying to do.


-- 

Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor