Re: Trouble Downloading Python and Numpy

2019-05-29 Thread Shakti Kumar
On Wed, 29 May 2019 at 9:38 PM Shakti Kumar 
wrote:

>
>
> On Wed, 29 May 2019 at 9:29 PM Contreras, Brian J 
> wrote:
>
>> Good Morning,
>>
>> I am a research student at the Georgia Institute of Technology. I have
>> made multiple attempts to download different versions of Python with Numpy
>> on my Microsoft Surface Book with no success.
>>
>
> Since you need numpy and as a grad student too, I'll strongly suggest you
> to look for "installing anaconda on Windows". It's GUI based installation
> would be a good start especially for people who are struggling with python
> installations on windows.
>

Forgot to mention this,
Anaconda comes prepackaged with numpy, pandas, scripy and other data
analysis libs. So you won't need to pip/conda install them separately


>
>> (Clipped for brevity)
>
>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
> --
> Sent from Shakti’s iPhone
>
-- 
Sent from Shakti’s iPhone
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trouble Downloading Python and Numpy

2019-05-29 Thread Shakti Kumar
On Wed, 29 May 2019 at 9:29 PM Contreras, Brian J 
wrote:

> Good Morning,
>
> I am a research student at the Georgia Institute of Technology. I have
> made multiple attempts to download different versions of Python with Numpy
> on my Microsoft Surface Book with no success.
>

Since you need numpy and as a grad student too, I'll strongly suggest you
to look for "installing anaconda on Windows". It's GUI based installation
would be a good start especially for people who are struggling with python
installations on windows.


> (Clipped for brevity)
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Sent from Shakti’s iPhone
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Implementing C++'s getch() in Python

2019-05-26 Thread Shakti Kumar
On Sun, 26 May 2019 at 20:23,  wrote:
>
> I've run getpass() on IDLE, Spyder, PyCharm and Mu. All with negative results.
>
>
As Random832 pointed out, these IDEs cannot handle the stdout/stdin with getpass
You should use a normal terminal (command prompt) on your windows for
running this program.

You can read more here, https://docs.python.org/3.1/library/getpass.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Implementing C++'s getch() in Python

2019-05-25 Thread Shakti Kumar
On Sat, 25 May 2019 at 4:43 PM  wrote:

> I'm working on Python 3.7 under Windows. I need a way to input characters
> without echoing them on screen, something that getch() did effectively in
> C++.


try getpass module.
Typically this would be,

import getpass
variable = getpass.getpass('your prompt')


> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Sent from Shakti’s iPhone
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Django Potential Fork Bomb

2019-05-09 Thread Shakti Kumar
On Thu, 9 May 2019 at 18:02, Skip Montanaro 
wrote:
>
> > > In this case, you might get better answers when you describe your
problem in a
> > > specialize "Django" list.
>
> > Any leads for some groups?
>
> Django-users?
>
> https://docs.djangoproject.com/en/dev/internals/mailing-lists/
>
> FWIW, I'm not a Django user, but found this page with a simple Google
> search for "Django mailing list”.

Thanks a lot, will keep that in mind.


-- 
Shakti Kumar,
Grad Student,
Dept. of Computer Science,
University of Toronto
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Django Potential Fork Bomb

2019-05-09 Thread Shakti Kumar
On Thu, 9 May 2019 at 10:27, dieter  wrote:
>
> Shakti Kumar  writes:
> > ...
> > I suspect django spawned too many child processes, and consecutively I ran
> > out of resources on my dev server. How can I prevent this from happening?
> > And I am not able to understand why django should spawn (if it indeed is
> > spawning) incrementing processes with each query from the GUI.
>
> I suspect the GUI to be the culprit. You have not told us what
> kind of GUI this is: is it the (standard) GUI which comes with "Django"
> (and runs in your browser)?

Yes the standard GUI shipped with Django.

> In this case, you might get
> better answers when you describe your problem in a specialize "Django"
> list.

Any leads for some groups?

Thanks a lot,
Shakti.
-- 
https://mail.python.org/mailman/listinfo/python-list


Django Potential Fork Bomb

2019-05-08 Thread Shakti Kumar
Hello team,

I am using django runserver 0.0.0.0: for one of my dev server.
However, I notice that a second query from the GUI executes any command in
my python app twice (I could see 2 prints), a third query executes it three
times, and so on.

This kept growing with each query and today my dev server stopped
responding due to too many processes. For any command I executed on my dev
server upon logging in, the error I received was,

Last login: Wed May 8 07:34:29 2019 from 2001:420:c0e0:1003::13b
-bash: fork: retry: No child processes
-bash: fork: retry: No child processes
-bash: fork: retry: No child processes
-bash: fork: retry: No child processes
-bash: fork: Resource temporarily unavailable

I was able to ask one of my colleagues to kill the django process, and
after that all the commands came back to life for me.

I suspect django spawned too many child processes, and consecutively I ran
out of resources on my dev server. How can I prevent this from happening?
And I am not able to understand why django should spawn (if it indeed is
spawning) incrementing processes with each query from the GUI.

Looking out for some suggestions/help.

Thanks,
Shakti

-- 
Shakti Kumar,
Grad Student,
Dept. of Computer Science,
University of Toronto
-- 
https://mail.python.org/mailman/listinfo/python-list


Re:

2019-04-19 Thread Shakti Kumar
On Fri, 19 Apr 2019 at 11:19 PM Tamara Berger  wrote:

> Hi Shaki,
>
> Thanks for your reply. I tried your code, but it didn't work. Here is the
> section of code and your addition:
>
>if ((monthly_salary*t)*compound_int)   print('It is not possible to save for the downpayment in 36 months.')
>   break
>   import sys
>   sys.exit()
>

Include the sys.exit() before the break.
You cannot have two branching statements in the same block.
So it'd be,

if ((monthly_salary*t)*compound_int) Thanks,
> Tamara
>
>
> On Fri, Apr 19, 2019 at 1:23 PM Shakti Kumar <
> shakti.shrivastav...@gmail.com> wrote:
>
>>
>>
>> On Fri, 19 Apr 2019 at 9:33 PM Tamara Berger  wrote:
>>
>>> Hi Python-List,
>>>
>>> What code can I use to break out of a program completely, and not just
>>> out
>>> of a loop?
>>
>>
>> import sys
>> sys.exit()
>>
>> Should do your work.
>>
>>>
>>
>> I wrote code with 3 conditions for saving for a downpayment. The
>>> first addresses cases that don't meet the minimum condition; i.e., enough
>>> money to save for a downpayment within the allotted time. It has its own
>>> print line, but also executes the irrelevant print lines for the other
>>> two
>>> conditions.
>>
>>
>> However anyone would suggest to put the prints in the proper if else
>> block rather than going for an exit.
>>
>>>
>>
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>>
>>
>> Thanks,
>> Shakti.
>>
>>> <https://mail.python.org/mailman/listinfo/python-list>
>>>
>> --
>> Sent from Shakti’s iPhone
>>
> --
Sent from Shakti’s iPhone
-- 
https://mail.python.org/mailman/listinfo/python-list


Re:

2019-04-19 Thread Shakti Kumar
On Fri, 19 Apr 2019 at 9:33 PM Tamara Berger  wrote:

> Hi Python-List,
>
> What code can I use to break out of a program completely, and not just out
> of a loop?


import sys
sys.exit()

Should do your work.

>

I wrote code with 3 conditions for saving for a downpayment. The
> first addresses cases that don't meet the minimum condition; i.e., enough
> money to save for a downpayment within the allotted time. It has its own
> print line, but also executes the irrelevant print lines for the other two
> conditions.


However anyone would suggest to put the prints in the proper if else block
rather than going for an exit.

>

> --
> https://mail.python.org/mailman/listinfo/python-list


Thanks,
Shakti.

> 
>
-- 
Sent from Shakti’s iPhone
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stack Overflow Developer Survey

2019-04-14 Thread Shakti Kumar
It is certainly worth the mention!
Kudos to all the core devs and the volunteers here for their
dedication making Python the Most Wanted and Second Most Loved
programming language this time !

Thanks,
Shakti


On Sun, 14 Apr 2019 at 12:14, Frank Millman  wrote:
>
> Hi all
>
> Stack Overflow have just published the results of their 2019 Developer
> Survey. Here is the link -
>
> https://insights.stackoverflow.com/survey/2019?utm_source=Iterable_medium=email_campaign=dev-survey-2019
>
> They summarise some of the top 'takeaways'. This is first on the list -
>
> """
> Python, the fastest-growing major programming language, has risen in the
> ranks of programming languages in our survey yet again, edging out Java
> this year and standing as the second most loved language (behind Rust).
> """
>
> I thought it was worth a mention.
>
> Frank Millman
>
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Kill stuck threads

2019-04-09 Thread Shakti Kumar
Hello Team,

Over due course I've felt the need of a way to kill a thread gracefully, by
relieving all occupied resources.
A bit of search online shows me that killing a thread depends very much on
the underlying platform support, and is something not advised, however I
face this problem when one of my devices don't respond and my code keeps
waiting indefinitely for an SSH reply.
I figured I could find a way out of the stuck situation by launching a
thread to do the SSH, and raising an exception from main thread if the SSH
thread isn't complete in 20seconds (max time for our devices' login).
But since a Django frontend (for my application) won't kill the stuck
thread, or even the bareminimum python won't, I'm pretty sure I'll run into
resource issue when many users have used the application for non responsive
devices.
I can get around with a timeout value in the pexpect module I'm using for
SSHing, but wanted to check if there's a solution already of getting around
the thread issue.

Best,
Shakti.
-- 
Sent from Shakti’s iPhone
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [RELEASE] Python 2.7.16 release candidate 1

2019-02-16 Thread Shakti Kumar
On Sun, 17 Feb 2019 at 6:44 AM Benjamin Peterson 
wrote:

> I'm pleased to announce the immediate availability of Python 2.7.16
> release candidate 1. This is a prerelease for yet another bug fix release
> in the Python 2.7.x series. It includes over 100 fixes over Python 2.7.15.
> See the changelog at


> https://raw.githubusercontent.com/python/cpython/baacaac06f93dd624c9d7b3bac0e13fbe34f2d8c/Misc/NEWS.d/2.7.16rc1.rst

(Clipped for brevity)

>
> 
> If all goes according to plan, Python 2.7.16 final will be released on
> March 2.


> Just a small doubt (out of curiosity), python 2.7 is nearing end of
support right?
-- 
Sent from Shakti’s iPhone
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unable to install Python 3

2019-01-27 Thread Shakti Kumar
On Sun, 27 Jan 2019 at 18:44, Hemant Mehta 
wrote:
>
> Dear Team,
>
> I am unable to install python 3 in my computer.
> Kindly find my system configuration details & error details occured at
the time of installation.

Unable to find the system configuration details & error details.
> *Please do the needful on priority.*
>
>
> Regards,
> Hemant Mehta
> --
> https://mail.python.org/mailman/listinfo/python-list



--
-- 
https://mail.python.org/mailman/listinfo/python-list


mocking for get method in requests

2019-01-18 Thread Shakti Kumar
Hello people,
I noticed something weird (weird as per my current knowledge, though I know
its subjective) today.

sample.py file

--

import requests
def random_testing():
out = requests.get('www.cisco.com')
a = out.json()
return a


testing.py file

--

@patch(*’*sample.requests')
def test_random_testing(self, mock_req):
mock_req.get('').return_value = 'Hello'
out = api.random_testing()


Patching the sample.requests in this way does not lead the output of
requests.get() function in sample.py file to be ‘Hello’ as indicated
in
mock_req.get('').return_value = 'Hello'
Instead, it creates a new field called return_value in ‘out', and
hence out.return_value is ‘Hello’ instead of just ‘out’.

But if I patch it as,

@patch(*’*sample.requests')
def test_random_testing(self, mock_req):
mock_req.get.return_value = 'Hello'
out = api.random_testing()

It does give the value of ‘out’ as ‘Hello’ in sample.py file.
I know I am missing something, which is where I need some help :)

Thanks.

-- 



UG, CSE,
RVCE, Bengaluru.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: clusters of numbers

2018-12-15 Thread Shakti Kumar
On Sun, 16 Dec 2018 at 09:49, Vincent Davis  wrote:
>
> Why not start with a histogram.
>
> Vincent
>
> On Sat, Dec 15, 2018 at 6:46 PM Marc Lucke  wrote:
>
> > hey guys,
> >
> > I have a hobby project that sorts my email automatically for me & I want
> > to improve it.  There's data science and statistical info that I'm
> > missing, & I always enjoy reading about the pythonic way to do things too.
> >
> > I have a list of percentage scores:

[clipped for brevity]

> > That algorithm is entirely untested & I think it could work, it's just I
> > don't want to reinvent the wheel.  Any ideas kindly appreciated.
> >
> >
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
> --
> https://mail.python.org/mailman/listinfo/python-list

+1 for k means certainly.
Also k means in 1D will be like a simple distance comparison and
assignment. A quick Google will give you the exact codes for doing so.
It will be you yourself who will decide how many clusters you want, as
Avi has rightly pointed out.


--
/Shakti
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading 'scientific' csv using Pandas?

2018-11-19 Thread Shakti Kumar
Hi Martin,

On Sun, 18 Nov 2018 at 23:59, Martin Schöön  wrote:
>
> Den 2018-11-18 skrev Shakti Kumar :
> > On Sun, 18 Nov 2018 at 18:18, Martin Schöön  wrote:
> >>
> >> Now I hit a bump in the road when some of the data is not in plain
> >> decimal notation (xxx,xx) but in 'scientific' (xx,xxxe-xx) notation.
> >>
> >
> > Martin, I believe this should be done by pandas itself while reading
> > the csv file,
> > I took an example in scientific notation and checked this out,
> >
> > my sample.csv file is,
> > col1,col2
> > 1.1,0
> > 10.24e-05,1
> > 9.492e-10,2
> >
> That was a quick answer!
>
> My pandas is up to date.
>
> In your example you use the US convention of using "." for decimals
> and "," to separate data. This works perfect for me too.
>
> However, my data files use European conventions: decimal "," and TAB
> to separate data:
>
> col1col2
> 1,1 0
> 10,24e-05   1
> 9,492e-10   2
>

A quick fix would be to replace all commas in your file with stops (.)
In case you have other stops in your file not necessarily in your
scientific notation columns only, you may do this replace process only
for your interested columns.
Meanwhile I should be looking for a cleaner way of loading this csv in
pandas, never came through this comma notation :)
Members of @python-list@python.org, any better solution?

> I use
>
> EUData = pd.read_csv('file.csv', skiprows=1, sep='\t',
> decimal=',', engine='python')
>
> to read from such files. This works so so. 'Common floats' (3,1415 etc)
> works just fine but 'scientific' stuff (1,6023e23) does not work.
>
> /Martin
> --
> https://mail.python.org/mailman/listinfo/python-list



-- 
Shakti.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading 'scientific' csv using Pandas?

2018-11-18 Thread Shakti Kumar
On Sun, 18 Nov 2018 at 18:18, Martin Schöön  wrote:
>
> I am in this project where I try to get an overview of a bunch of
> computer generated (finite element program) data. I have it stored in a
> number of csv files.
>
> Reading the data into spreadsheet programs works fine but is very labour
> intensive so I am working with Pandas in Jupyter notebooks which I find
> much more efficient.
>
> Now I hit a bump in the road when some of the data is not in plain
> decimal notation (xxx,xx) but in 'scientific' (xx,xxxe-xx) notation.
>

Martin, I believe this should be done by pandas itself while reading
the csv file,
I took an example in scientific notation and checked this out,

my sample.csv file is,
col1,col2
1.1,0
10.24e-05,1
9.492e-10,2

and then I execute,
In [29]: a= pd.read_csv('sample.csv')
In [30]: a.values
Out [30]:
array([[1.100e+00, 0.000e+00],
   [1.024e-04, 1.000e+00],
   [9.492e-10, 2.000e+00]])
In [31]: a.values[1][0]
Out[31]: 0.0001024
As you can see, pandas has converted scientific notation to float,
even the data type of these values is numpy.float64

What best I can guess is a problem with your pandas version, there
were some updates with the 0.17.x coming in, maybe give a shot
upgrading your pandas with,
pip install --upgrade pandas
or in case you’re using anaconda then,
conda update pandas

> [snipped for brevity]
> /Martin
> --
> https://mail.python.org/mailman/listinfo/python-list

-- 
Shakti.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Issue in parsing the strings in python code

2018-11-12 Thread Shakti Kumar
On Mon, 12 Nov 2018 at 14:02, srinivasan  wrote:

> Dear Python Experts team,
>
> This question might be very simple for you, As am newbie to python, could
> you please how to parse the below strings
>
> 1. Could you please do the needful in guiding me, that how can I extract
> the strings under the UUID column in python code in the below output (nmcli
> c show), I need to extract the UUID of "Funkloch" ie.,
> "1da7d068-4548-4446-bf88-a440e49db1b1" for "TYPE" wifi and device "wlp1s0"
> and return this string ("1da7d068-4548-4446-bf88-a440e49db1b1") to the
> robotframework?
>

> root:~/qa/robot_tests# nmcli c show
> NAMEUUID  TYPE  DEVICE
>
> Funkloch 1552 c8e1e8c0-0f25-4299-a9ae-2910cfef2ebd  wifi  wlp1s0
>
> Wired connection 1  2a14fbe6-58a0-3b7f-b986-5d1b36a94ec0  ethernet
> enp0s21f0u4
> Funkloch  1da7d068-4548-4446-bf88-a440e49db1b1  wifi  --
>
> Funkloch 10   f4d9ce13-aab0-4485-9929-6070ad52a196  wifi  --
>
> Funkloch 100  8b48a220-1754-4988-84ad-d0f83a9b4ede  wifi  --
>
>
>
> 2. Similarly, As I need to verify whether the DEVICE "wlp1s0" is connected
> to "Funkloch" or not? could you please help me, how can I extract the
> "connected" status under "STATE column for DEVICE "wlp1s0" and CONNECTION
> "Funkloch 1552"
>
> root:~/qa/robot_tests# nmcli dev
> DEVICE   TYPE  STATECONNECTION
> enp0s21f0u4  ethernet  connectedWired connection 1
> wlp1s0   wifi  connectedFunkloch 1552
> enp2s0   ethernet  unavailable  --
> sit0 iptunnel  unmanaged--
> lo   loopback  unmanaged--
>
> Kindly do the needful as am trying this from past two 2 days, still no
> clues
>
> Many thanks in advance
> --
> https://mail.python.org/mailman/listinfo/python-list
>

You can look into textfsm parser for the same, it was released specifically
for this purpose of parsing CLI outputs.
It should be the ideal solution for your scenario since I see some rows in
your cli output which have spaces in the same column, so a hardcoded index
after splitting each line on spaces will not work out.
-- 
https://mail.python.org/mailman/listinfo/python-list


Fwd: socket: Too many open files

2018-10-14 Thread Shakti Kumar
>On 13Oct2018 14:10, Shakti Kumar  wrote:
>>I’m running a script which basically does a traceroute to the list of
>>hosts
>>provided, and then pulls up some info by logging in to gateways in the
path.
>>I am running this script for a list of almost 40k hosts in our data
centers.
>>Also, I am using commands module to get the traceroute output.
>>
>>out = commands.getstatusoutput('traceroute ' + ip)
>>
>>However I observe that this particular line is failing with socket error
>>after I reach some 5k to 6k hosts.
>>I know commands module is using pipes to execute the given command and
this
>>is one reason for exhaustion of file descriptors.
>>Any suggestions for improving this and getting a workaround?

>I'd figure out where your file descriptors are going.

>Is traceroute leaving sockets littering your system? If you're on Linux
>this command:

>  netstat -anp

>will show you all the sockets, their state, and the pids of the
>processes which own them. Does your script cause sockets to accrue after
>the traceroutes?

>If you write a trivial shell script to do the traceroutes:

>while read ip
>do
>traceroute $ip
>  done does it also exhibit the problem?

>The if doesn't, then traceroute may not be the problem and something
>else is leaking file descriptors.

>In fact, given that it is file descriptors, maybe sockets are not what
>is leaking?

>From another terminal, see what your Python programme has open when this
>happens with "lsof -n -p pid-of-python-programme". Maybe the leaks are
>pipes, or connections from your "logging in to gateways in the path"
>code. It may be as simple as you not closing files or connections.

>Cheers,
>Cameron Simpson 

Thanks Cameron, I still cant get over the fact that you were able to pin
point the issue even without looking at my code XD
Indeed when I started looking for sockets, I realised I was not closing
connections to ACI hosts in our datacentres, and the error was starting to
pop up at around 2900 to 3k TCP connections open to the hosts. XD

Thanks Jonathan for pointing me to more apt functions. It helped a lot :)

Regards,
Shakti.
-- 
https://mail.python.org/mailman/listinfo/python-list


Fwd: socket: Too many open files

2018-10-13 Thread Shakti Kumar
>Hello,
>I’m running a script which basically does a traceroute to the list of
hosts provided, and then pulls up some info by logging in to gateways in
the path.
>I am running this script for a list of almost 40k hosts in our data
centers.
>Also, I am using commands module to get the traceroute output.

>out = commands.getstatusoutput('traceroute ' + ip)

>However I observe that this particular line is failing with socket error
after I reach some 5k to 6k hosts.
>I know commands module is using pipes to execute the given command and
this is one reason for exhaustion of file descriptors.
>Any suggestions for improving this and getting a workaround?

>Thanks,
>Shakti

I dont understand how I should close the socket created by commands module
after I do traceroute to one host.
Also, if I’m not wrong, isn’t commands module supposed to do that on its
own?
-- 
https://mail.python.org/mailman/listinfo/python-list


socket: Too many open files

2018-10-13 Thread Shakti Kumar
Hello,
I’m running a script which basically does a traceroute to the list of hosts
provided, and then pulls up some info by logging in to gateways in the path.
I am running this script for a list of almost 40k hosts in our data centers.
Also, I am using commands module to get the traceroute output.

out = commands.getstatusoutput('traceroute ' + ip)

However I observe that this particular line is failing with socket error
after I reach some 5k to 6k hosts.
I know commands module is using pipes to execute the given command and this
is one reason for exhaustion of file descriptors.
Any suggestions for improving this and getting a workaround?

Thanks,
Shakti
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem finding my folder via terminal

2018-06-06 Thread Shakti Kumar
Hi Berger,
Do you have any space in the absolute path for mymodules? Spaces avoid
getting the correct path as I had seen in one of my virtual environments.

Shakti.

On Wed, Jun 6, 2018, 9:53 PM T Berger  wrote:

> I’m learning Python on my own and have been stuck for two days trying to
> get modules I created into site-packages. As a trial step, we were asked to
> change directly into the folder containing our modules. I typed “cd
> mymodules” per instructions, but got this error message: “-bash: cd:
> mymodules: No such file or directory.” I saved mymodules to my documents.
> What is going wrong here?
>
> When I tried to create a distribution file, I typed “192:~ TamaraB$
> mymodules$ python3 setup.py sdist.” I got this error message: “-bash:
> mymodules$: command not found.” What should I do?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list