How to get filesystem in python.

2020-01-17 Thread Antoon Pardon
I would like to get the information given by the df command on linux/unix.
I found the os.statvfs call, but it misses one thing: The filesystem.

Does anyone know how to get that information.

-- 
Antoon.

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


[no subject]

2020-01-17 Thread kiran chawan
Hi,  Sir my self kiran chawan studying in engineering and I have HP PC  and
windows edition is window 10, system type 64-bit operating system.  So tell
me which python version software is suitable for my PC okay and send me
that software direct link okay thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to get filesystem in python.

2020-01-17 Thread Cousin Stanley
Antoon Pardon wrote:

> I would like to get the information given by the df command on linux/unix.
> I found the os.statvfs call, but it misses one thing: The filesystem.
> 
> Does anyone know how to get that information.
> 

import os

pipe_in = os.popen( 'df -h -T -x tmpfs -x devtmpfs' )

list_source = pipe_in.readlines()

for this_item in list_source[ 1 : ] :

this_list = this_item.strip().split()

file_sys  = this_list[ 0 ]
file_type = this_list[ 1 ]
size  = this_list[ 2 ]
used  = this_list[ 3 ]
avail = this_list[ 4 ]
used_pc   = this_list[ 5 ]
mounted   = this_list[ 6 ]


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: How to get filesystem in python.

2020-01-17 Thread Python

Le 17/01/2020 à 11:35, Antoon Pardon a écrit :

I would like to get the information given by the df command on linux/unix.
I found the os.statvfs call, but it misses one thing: The filesystem.

Does anyone know how to get that information.



https://stackoverflow.com/questions/25283882/determining-the-filesystem-type-from-a-path-in-python
--
https://mail.python.org/mailman/listinfo/python-list


Re:

2020-01-17 Thread Bob Gailer
On Jan 17, 2020 5:37 AM, "kiran chawan"  wrote:
>
> Hi,  Sir my self kiran chawan studying in engineering and I have HP PC
and
> windows edition is window 10, system type 64-bit operating system.  So
tell
> me which python version software is suitable for my PC okay and send me
> that software direct link

Try this link:

 Windows x86-64 executable installer


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


Fun with IO

2020-01-17 Thread Frank Millman

Hi all

I just tried something that I did not think had a snowball's chance of 
working, but to my surprise it did. I thought I would share it, partly 
for interest, and partly in case anyone can foresee any problems with it.


I use ReportLab to generate pdf files. I do not write them to disk, but 
use BytesIO to store them in memory. There are two main scenarios - send 
an email and attach a pdf (which I have not addressed yet), and stream a 
pdf via HTTP for display in a browser (which is the subject of this post).


I use asyncio, which accepts a request from a client and passes a 
client_reader and a client_writer to my handler. This is how I handle a 
pdf request at present -


with io.BytesIO() as pdf_fd:
await pdf_handler(pdf_fd)
pdf_fd.seek(0)  # rewind
client_writer.write(pdf_fd.read())
client_writer.write(b'\r\n')

I actually write it in 'chunks', but omitted that to keep it simple.

It works perfectly. However, some pdf's can be large, and there could be 
concurrent requests, so I wanted to minimise the memory footprint. So I 
tried passing the client_writer directly to the handler -


await pdf_handler(client_writer)
client_writer.write(b'\r\n')

It works! ReportLab accepts client_writer as a file-like object, and 
writes to it directly. I cannot use chunking, so I just let it do its thing.


Can anyone see any problem with this?

Thanks

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


problem related to using pip

2020-01-17 Thread Ayush Srivastava
when i was running this code on cmd of latest versin of python3.8.1  i got
this error

pip install qsharp


*output*
Unable to create process using 'C:\ProgramData\Anaconda3\python.exe
C:\ProgramDa
ta\Anaconda3\Scripts\pip-script.py install qsharp'
-- 
https://mail.python.org/mailman/listinfo/python-list


problem

2020-01-17 Thread mrunali


I am face a problem to download MySQL for python as well as I can not able to 
install kivy on my laptop . please give me solution for it .
Sent from Mail for Windows 10

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


Re: Fun with IO

2020-01-17 Thread Chris Angelico
On Sat, Jan 18, 2020 at 6:09 AM Frank Millman  wrote:
> So I
> tried passing the client_writer directly to the handler -
>
>  await pdf_handler(client_writer)
>  client_writer.write(b'\r\n')
>
> It works! ReportLab accepts client_writer as a file-like object, and
> writes to it directly. I cannot use chunking, so I just let it do its thing.
>
> Can anyone see any problem with this?
>

Looks good to me! The only potential problem would be if the
pdf_handler needs a seekable file-like object (eg if it needs to write
a header that contains the size of the entire file), but it appears to
work, so you're almost certainly safe.

In more general terms, what you've done is basically write directly to
the socket, rather than writing to a mythical file and storing it in
memory, then dumping that memory out to the socket. Which (as long as
you don't need to seek or edit) is absolutely an acceptable way to do
things, and is likely to give better performance.

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


Re: problem related to using pip

2020-01-17 Thread MRAB

On 2020-01-17 15:09, Ayush Srivastava wrote:

when i was running this code on cmd of latest versin of python3.8.1  i got
this error

pip install qsharp


*output*
Unable to create process using 'C:\ProgramData\Anaconda3\python.exe
C:\ProgramDa
ta\Anaconda3\Scripts\pip-script.py install qsharp'

"pip" is used by the standard distribution, from the Python Software 
Foundation.


I believe that Anaconda has its own tool called "conda":

https://pypi.org/project/qsharp/
--
https://mail.python.org/mailman/listinfo/python-list


Re: problem

2020-01-17 Thread DL Neil via Python-list

On 18/01/20 7:39 AM, mrunali wrote:


I am face a problem to download MySQL for python as well as I can not able to 
install kivy on my laptop . please give me solution for it .
Sent from Mail for Windows 10



How did you try to download MySQL?
Which MySQL Connector?
What was the error message?


How did you try to download MySQL^h^h^h^h^hKivy?
etc


Be aware that this is a cooperative list not a paid-support system.
--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: How to get filesystem in python.

2020-01-17 Thread Cameron Simpson

On 17Jan2020 11:35, Antoon Pardon  wrote:

I would like to get the information given by the df command on linux/unix.
I found the os.statvfs call, but it misses one thing: The filesystem.

Does anyone know how to get that information.


If you os.stat() the same thing you statvfs()ed you get an st_dev field, 
which identifies the filesystem in principle. You still need to consult 
the system mount table to get a path to its root though.


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Modify Python code as newbie

2020-01-17 Thread ron . eggler
Hi,

I'm semi new to Python but need to modify a program that calls the 
mqtt_client.publish()  function from aws iot.
Now, if the publish function fails, it raises an exception.  I need to change 
the code so that when an exception is raised, instead of giving up, it should 
retry.
Here's some semi pseudo code of what I came up with and what I'm particularly 
interested in is, if the exception in pub_msg() is raised, will my thread t 
keep running? 
What else could/should be improved about the below snippet? I'm looking forward 
to get some inputs.

Thanks!


import retrying
import Queue as queue
import threading as th
NUM_THREADS=1
numth=[]
def worker():
while not_terminated():
item = q.get()
if item is None:
continue
do_stuff(item)

def enQ(self, msg, topic):
if len(numthhttps://mail.python.org/mailman/listinfo/python-list


modify python code as newbie

2020-01-17 Thread ron . eggler
Hi,

I'm semi new to Python but need to modify a program that calls the 
mqtt_client.publish()  function from aws iot.
Now, when the publish function fails, it raises an exception.  I need to change 
the code so that when an exception is raised, instead of giving up, it should 
retry (indefinitely).
Here's some semi pseudo code of what I came up with: 
What I'm particularly interested in is, if when the exception in pub_msg() is 
raised, will my thread t keep running? 
What else could/should be improved in the below snippet? I'm looking forward to 
get some inputs.

Thanks!


import retrying
import Queue as queue
import threading as th
NUM_THREADS=1
nth=[]
def worker():
while not_terminated():
item = q.get()
if item is None:
continue
do_stuff(item)

def enQ(self, msg, topic):
if len(nthhttps://mail.python.org/mailman/listinfo/python-list


Re: Modify Python code as newbie

2020-01-17 Thread MRAB

On 2020-01-18 00:34, [email protected] wrote:

Hi,

I'm semi new to Python but need to modify a program that calls the 
mqtt_client.publish()  function from aws iot.
Now, if the publish function fails, it raises an exception.  I need to change 
the code so that when an exception is raised, instead of giving up, it should 
retry.
Here's some semi pseudo code of what I came up with and what I'm particularly 
interested in is, if the exception in pub_msg() is raised, will my thread t 
keep running?
What else could/should be improved about the below snippet? I'm looking forward 
to get some inputs.

Thanks!


>
> import retrying
> import Queue as queue

Is this Python 2? In Python 3 it's called "queue".

> import threading as th
> NUM_THREADS=1
> numth=[]
> def worker():
>  while not_terminated():
>  item = q.get()
>  if item is None:
>  continue
>  do_stuff(item)
>
> def enQ(self, msg, topic):
>  if len(numth  t = th.Thread(target=worker)
>  t.start()
>  numth.append(t)
>  q.put([self,msg,topic])
>
> def do_stuff(dat):
>  self= dat[0]
>  msg = dat[1]
>  topic   = dat[2]
>  pub-msg(slef, msg, topic)

The "-" should be "_" and "slef" should be "self".

>
> def send_msg(self, msg,topic):
>  enQ(self,msg,topic)
>
> def pub_msg(self,msg,topic):
>  try:
>  if topic == "test" and \
>  something[self.xyz]:
>  return
>  except KeyError as err:
>  foo("Exception {}".format(err))

"except" block is indented too much.

If there's a key error, it'll call "foo" (whatever that is) and then 
continue.

>
>  aws_publish(self,msg,topic)
>
> @retry (wait_random_min=1000, wait_random_max=2000)
> def aws_publish(self.msg,topic):

"." instead of ",".

>  self.__mqtt_client.publish(
>  "/{}/{}".format(topic, self._uuid), msg_json, 1)
>
--
https://mail.python.org/mailman/listinfo/python-list