Angular distribution rose diagram in Python

2019-09-27 Thread Madhavan Bomidi
Hi,

Can someone help me to make python code (with some arbitrary data) for the 
angular distribution rose diagram as shown in figure 7 in the paper accessible 
through the web-link: 

https://www.nat-hazards-earth-syst-sci.net/17/1425/2017/nhess-17-1425-2017.pdf

Thanks in advance
Madhavan
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-27 Thread RobH

On 27/09/2019 04:51, Dennis Lee Bieber wrote:

On Thu, 26 Sep 2019 23:04:15 +0100, RobH  declaimed the
following:





As I said, I have downloaded the circuitpython chalcd files from the
link using pip3 install, but after downloading I can't find any Adafruit
folders on my pi zero. Doing a search for adafruit does not show anything.



Did you also install the adafruit-blinka library?

On a Beaglebone Black (my R-Pi is in the depth of major apt-get
update/upgrade cycle -- it feels like it's updating 50% of the OS given how
long it's been running, and that's on a 3B+ quadcore compared to the slower
single core BBB) I find blinka in

debian@beaglebone:~$ sudo find / -iname "*blinka*"
/usr/local/lib/python3.5/dist-packages/Adafruit_Blinka-2.5.0-py3.5.egg-info
/usr/local/lib/python3.5/dist-packages/adafruit_blinka
debian@beaglebone:~$

Note: I ran the installs using "sudo pip3 ..." to make things act
globally; if you ran without sudo the files might be in a hidden directory
of the "pi" account.

Okay, an incomplete search of the R-Pi, stealing cycles from the
upgrade processing)

pi@raspberrypi:~$ sudo find / -iname "*adafruit*"

/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO
/usr/local/lib/python3.7/dist-packages/adafruit_blinka
/usr/local/lib/python3.7/dist-packages/Adafruit_PlatformDetect-1.3.4.dist-info
/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO-0.2.3.dist-info
/usr/local/lib/python3.7/dist-packages/Adafruit_Blinka-2.5.1.dist-info
/usr/local/lib/python3.7/dist-packages/adafruit_platformdetect





Ok, the adafruit_character_lcd is in the same directory as yours, and so 
is Blinka and Purio. It seems to be a bit of a long path to type to get 
to the Adafruit_Charlcd directory, but is there a shortcut way of 
getting to the said directory.


Thanks

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


Recursive method in class

2019-09-27 Thread ast

Hello

Is it feasible to define a recursive method in a class ?
(I don't need it, it's just a trial)

Here are failing codes:


class Test:
def fib(self, n):
if n < 2: return n
return fib(self, n-2) + fib(self, n-1)

t = Test()

t.fib(6)

-
Traceback (most recent call last):
return fib(self, n-2) + fib(self, n-1)
NameError: name 'fib' is not defined
-

An other try:

class Test:
@staticmethod
def fib(n):
if n < 2: return n
return fib(n-2) + fib(n-1)

t = Test()
t.fib(6)


Traceback (most recent call last):
return fib(n-2) + fib(n-1)
NameError: name 'fib' is not defined
-
--
https://mail.python.org/mailman/listinfo/python-list


How to publish a message of the qspinbox value when the qspinbox sets the slider with corresponding value.

2019-09-27 Thread Spencer Du
Hi

When the values of the spinboxes is set a message should be published from the 
GUI containing the value from the spinbox which then sets the qlabel with the 
value. After this if I close and reload the gui the widgets should be set with 
the values set from the previous time. When the embedded.py file closes/stops 
running the gui is reset to its default state when no spinbox and qlabel are 
set with values. 

First execute the embedded.py file. Enter 'laser' when 'devices to be 
activated' appears. Once this executed a publish and subscribe should happen 
and a laser actor python file starts which launches the laser device on the 
embedded.py file. Once this is complete launch GUI.py in a separate command 
line and click add device for the device in the combo box.

Here are the files needed.

embedded.py

import paho.mqtt.client as mqtt
from mqtt import *
import os
import time
import json

def start():
try:
os.remove("list_of_devices_currently_active.txt")
print("Awaiting devices to be activated")
except:
print("Awaiting devices to be activated")
start()

devices = list(map(str,input("Devices to be activated: ").split(",")))

client = device()
client.run()

client.loop_start()
print("Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI")
client.subscribe("microscope/light_sheet_microscope/UI")
print("Publishing message to topic", "microscope/light_sheet_microscope/UI")
client.publish("microscope/light_sheet_microscope/UI", json.dumps({"type": 
"system", "payload":{"name": devices, "cmd": "activating devices"}}, indent=2))
time.sleep(1)

def active_devices():
for item in devices:
device = (item + "Embedded")
deviceImport = __import__(device)

with open("list_of_devices_currently_active.txt", "a+") as myfile:
for item in devices:
myfile.write(item + "\n")

active_devices()

def readFile(fname):
print("List of devices currently active:")
try:
with open(fname, "r") as f:
for item in f:
print(item.rstrip("\n"))
except:
print("No devices added yet")
readFile("list_of_devices_currently_active.txt")

client = device()
client.run()

client.loop_start()
print("Connected to broker")
time.sleep(1)
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/states")
client.subscribe("microscope/light_sheet_microscope/UI/states")
client.loop_forever()

mqtt.py

import logging
import paho.mqtt.client as mqtt
import json

class device(mqtt.Client):
def on_connect(self, mqtt, obj, flags, rc):
pass

def on_message(self, mqtt, userdata, message):
m_decode = str(message.payload.decode("utf-8"))
print("message recieved= " + m_decode)
# print("File which you want to import(with .py extension)")
print("message topic=", message.topic)
print("message qos=", message.qos)
print("message retain flag=", message.retain)
m_in = json.loads(m_decode)

def run(self):
self.connect("localhost", 1883, 60)

GUI.py

import paho.mqtt.client as mqtt
import os
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5 import QtWidgets, uic
from mqtt import *
import json
import time

class MainWindow(QtWidgets.QMainWindow):
def __init__(self,parent = None):
QMainWindow.__init__(self)
super(MainWindow, self).__init__(parent)
self.mdi = QMdiArea()
self.setCentralWidget(self.mdi)

self.setMinimumSize(QSize(800, 600))
self.setWindowTitle("PyQt button example - 
pythonprogramminglanguage.com")

client = device()
client.run()

client.loop_start()
print("Connected to broker")
time.sleep(1)
print("Subscribing to topic", 
"microscope/light_sheet_microscope/UI/devices")
client.subscribe("microscope/light_sheet_microscope/UI/devices")
print("Publishing message to topic", 
"microscope/light_sheet_microscope/UI/devices")
client.publish("microscope/light_sheet_microscope/UI/devices", 
json.dumps({"type": "system", "payload":{"cmd": "get all devices"}}, indent=2))
time.sleep(1)

pybutton = QPushButton('Add device', self)

pybutton.clicked.connect(self.importbutton)

pybutton.move(100, 400)
pybutton.resize(150, 32)

self.combo = QComboBox(self)
self.combo.move(100,350)
self.combo.resize(100, 32)

def readFile(fname):
try:
with open(fname, "r") as f:
for item in f:
self.combo.addItem(item)
except:
print("No devices active")
readFile("list_of_devices_currently_active.txt") 

def importbutton(self):
client = device()
client.run()

client.loop_start()
print("Connected to broker")
time.sleep(1)
  

How to publish a message of the qspinbox value when the qspinbox sets the slider with corresponding value.

2019-09-27 Thread Spencer Du
Hi 

When the values of the spinboxes is set a message should be published from the 
GUI containing the value from the spinbox which then sets the qlabel with the 
value. After this if I close and reload the gui the widgets should be set with 
the values set from the previous time. When the embedded.py file closes/stops 
running the gui is reset to its default state when no spinbox and qlabel are 
set with values. 

First execute the embedded.py file. Enter 'laser' when 'devices to be 
activated' appears. Once this executed a publish and subscribe should happen 
and a laser actor python file starts which launches the laser device on the 
embedded.py file. Once this is complete launch GUI.py in a separate command 
line and click add device for the device in the combo box. 

Here are the files needed. 

embedded.py 

import paho.mqtt.client as mqtt 
from mqtt import * 
import os 
import time 
import json 

def start(): 
try: 
os.remove("list_of_devices_currently_active.txt") 
print("Awaiting devices to be activated") 
except: 
print("Awaiting devices to be activated") 
start() 
 
devices = list(map(str,input("Devices to be activated: ").split(","))) 

client = device() 
client.run() 

client.loop_start() 
print("Connected to broker") 
time.sleep(1) 
print("Subscribing to topic", "microscope/light_sheet_microscope/UI") 
client.subscribe("microscope/light_sheet_microscope/UI") 
print("Publishing message to topic", "microscope/light_sheet_microscope/UI") 
client.publish("microscope/light_sheet_microscope/UI", json.dumps({"type": 
"system", "payload":{"name": devices, "cmd": "activating devices"}}, indent=2)) 
time.sleep(1) 

def active_devices(): 
for item in devices: 
device = (item + "Embedded") 
deviceImport = __import__(device) 

with open("list_of_devices_currently_active.txt", "a+") as myfile: 
for item in devices: 
myfile.write(item + "\n") 

active_devices() 

def readFile(fname): 
print("List of devices currently active:") 
try: 
with open(fname, "r") as f: 
for item in f: 
print(item.rstrip("\n")) 
except: 
print("No devices added yet") 
readFile("list_of_devices_currently_active.txt") 

client = device() 
client.run() 

client.loop_start() 
print("Connected to broker") 
time.sleep(1) 
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/states") 
client.subscribe("microscope/light_sheet_microscope/UI/states") 
client.loop_forever() 

mqtt.py 

import logging 
import paho.mqtt.client as mqtt 
import json 

class device(mqtt.Client): 
def on_connect(self, mqtt, obj, flags, rc): 
pass 

def on_message(self, mqtt, userdata, message): 
m_decode = str(message.payload.decode("utf-8")) 
print("message recieved= " + m_decode) 
# print("File which you want to import(with .py extension)") 
print("message topic=", message.topic) 
print("message qos=", message.qos) 
print("message retain flag=", message.retain) 
m_in = json.loads(m_decode) 

def run(self): 
self.connect("localhost", 1883, 60) 

GUI.py 

import paho.mqtt.client as mqtt 
import os 
import sys 
from PyQt5.QtWidgets import * 
from PyQt5.QtCore import * 
from PyQt5 import QtWidgets, uic 
from mqtt import * 
import json 
import time 

class MainWindow(QtWidgets.QMainWindow): 
def __init__(self,parent = None): 
QMainWindow.__init__(self) 
super(MainWindow, self).__init__(parent) 
self.mdi = QMdiArea() 
self.setCentralWidget(self.mdi) 

self.setMinimumSize(QSize(800, 600)) 
self.setWindowTitle("PyQt button example - 
pythonprogramminglanguage.com") 

client = device() 
client.run() 

client.loop_start() 
print("Connected to broker") 
time.sleep(1) 
print("Subscribing to topic", 
"microscope/light_sheet_microscope/UI/devices") 
client.subscribe("microscope/light_sheet_microscope/UI/devices") 
print("Publishing message to topic", 
"microscope/light_sheet_microscope/UI/devices") 
client.publish("microscope/light_sheet_microscope/UI/devices", 
json.dumps({"type": "system", "payload":{"cmd": "get all devices"}}, indent=2)) 
time.sleep(1) 

pybutton = QPushButton('Add device', self) 

pybutton.clicked.connect(self.importbutton) 

pybutton.move(100, 400) 
pybutton.resize(150, 32) 

self.combo = QComboBox(self) 
self.combo.move(100,350) 
self.combo.resize(100, 32) 

def readFile(fname): 
try: 
with open(fname, "r") as f: 
for item in f: 
self.combo.addItem(item) 
except: 
print("No devices active") 
readFile("list_of_devices_currently_active.txt") 

def importbutton(self): 
client = device() 
 

How to publish a message of the qspinbox value when the qspinbox sets the slider with corresponding value.

2019-09-27 Thread Spencer Du
Hi 

When the values of the spinboxes is set a message should be published from the 
GUI containing the value from the spinbox which then sets the qlabel with the 
value. After this if I close and reload the gui the widgets should be set with 
the values set from the previous time. When the embedded.py file closes/stops 
running the gui is reset to its default state when no spinbox and qlabel are 
set with values. 

First execute the embedded.py file. Enter 'laser' when 'devices to be 
activated' appears. Once this executed a publish and subscribe should happen 
and a laser actor python file starts which launches the laser device on the 
embedded.py file. Once this is complete launch GUI.py in a separate command 
line and click add device for the device in the combo box. 

Here are the files needed. 

embedded.py 

import paho.mqtt.client as mqtt 
from mqtt import * 
import os 
import time 
import json 

def start(): 
try: 
os.remove("list_of_devices_currently_active.txt") 
print("Awaiting devices to be activated") 
except: 
print("Awaiting devices to be activated") 
start() 
 
devices = list(map(str,input("Devices to be activated: ").split(","))) 

client = device() 
client.run() 

client.loop_start() 
print("Connected to broker") 
time.sleep(1) 
print("Subscribing to topic", "microscope/light_sheet_microscope/UI") 
client.subscribe("microscope/light_sheet_microscope/UI") 
print("Publishing message to topic", "microscope/light_sheet_microscope/UI") 
client.publish("microscope/light_sheet_microscope/UI", json.dumps({"type": 
"system", "payload":{"name": devices, "cmd": "activating devices"}}, indent=2)) 
time.sleep(1) 

def active_devices(): 
for item in devices: 
device = (item + "Embedded") 
deviceImport = __import__(device) 

with open("list_of_devices_currently_active.txt", "a+") as myfile: 
for item in devices: 
myfile.write(item + "\n") 

active_devices() 

def readFile(fname): 
print("List of devices currently active:") 
try: 
with open(fname, "r") as f: 
for item in f: 
print(item.rstrip("\n")) 
except: 
print("No devices added yet") 
readFile("list_of_devices_currently_active.txt") 

client = device() 
client.run() 

client.loop_start() 
print("Connected to broker") 
time.sleep(1) 
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/states") 
client.subscribe("microscope/light_sheet_microscope/UI/states") 
client.loop_forever() 

mqtt.py 

import logging 
import paho.mqtt.client as mqtt 
import json 

class device(mqtt.Client): 
def on_connect(self, mqtt, obj, flags, rc): 
pass 

def on_message(self, mqtt, userdata, message): 
m_decode = str(message.payload.decode("utf-8")) 
print("message recieved= " + m_decode) 
# print("File which you want to import(with .py extension)") 
print("message topic=", message.topic) 
print("message qos=", message.qos) 
print("message retain flag=", message.retain) 
m_in = json.loads(m_decode) 

def run(self): 
self.connect("localhost", 1883, 60) 

GUI.py 

import paho.mqtt.client as mqtt 
import os 
import sys 
from PyQt5.QtWidgets import * 
from PyQt5.QtCore import * 
from PyQt5 import QtWidgets, uic 
from mqtt import * 
import json 
import time 

class MainWindow(QtWidgets.QMainWindow): 
def __init__(self,parent = None): 
QMainWindow.__init__(self) 
super(MainWindow, self).__init__(parent) 
self.mdi = QMdiArea() 
self.setCentralWidget(self.mdi) 

self.setMinimumSize(QSize(800, 600)) 
self.setWindowTitle("PyQt button example - 
pythonprogramminglanguage.com") 

client = device() 
client.run() 

client.loop_start() 
print("Connected to broker") 
time.sleep(1) 
print("Subscribing to topic", 
"microscope/light_sheet_microscope/UI/devices") 
client.subscribe("microscope/light_sheet_microscope/UI/devices") 
print("Publishing message to topic", 
"microscope/light_sheet_microscope/UI/devices") 
client.publish("microscope/light_sheet_microscope/UI/devices", 
json.dumps({"type": "system", "payload":{"cmd": "get all devices"}}, indent=2)) 
time.sleep(1) 

pybutton = QPushButton('Add device', self) 

pybutton.clicked.connect(self.importbutton) 

pybutton.move(100, 400) 
pybutton.resize(150, 32) 

self.combo = QComboBox(self) 
self.combo.move(100,350) 
self.combo.resize(100, 32) 

def readFile(fname): 
try: 
with open(fname, "r") as f: 
for item in f: 
self.combo.addItem(item) 
except: 
print("No devices active") 
readFile("list_of_devices_currently_active.txt") 

def importbutton(self): 
client = device() 
 

How to publish a message of the qspinbox value when the qspinbox sets the slider with corresponding value.

2019-09-27 Thread Spencer Du



Hi 

When the values of the spinboxes is set a message should be published from the 
GUI containing the value from the spinbox which then sets the qlabel with the 
value. After this if I close and reload the gui the widgets should be set with 
the values set from the previous time. When the embedded.py file closes/stops 
running the gui is reset to its default state when no spinbox and qlabel are 
set with values. 

First execute the embedded.py file. Enter 'laser' when 'devices to be 
activated' appears. Once this executed a publish and subscribe should happen 
and a laser actor python file starts which launches the laser device on the 
embedded.py file. Once this is complete launch GUI.py in a separate command 
line and click add device for the device in the combo box. 

Here are the files needed. 

embedded.py 

import paho.mqtt.client as mqtt 
from mqtt import * 
import os 
import time 
import json 

def start(): 
try: 
os.remove("list_of_devices_currently_active.txt") 
print("Awaiting devices to be activated") 
except: 
print("Awaiting devices to be activated") 
start() 
 
devices = list(map(str,input("Devices to be activated: ").split(","))) 

client = device() 
client.run() 

client.loop_start() 
print("Connected to broker") 
time.sleep(1) 
print("Subscribing to topic", "microscope/light_sheet_microscope/UI") 
client.subscribe("microscope/light_sheet_microscope/UI") 
print("Publishing message to topic", "microscope/light_sheet_microscope/UI") 
client.publish("microscope/light_sheet_microscope/UI", json.dumps({"type": 
"system", "payload":{"name": devices, "cmd": "activating devices"}}, indent=2)) 
time.sleep(1) 

def active_devices(): 
for item in devices: 
device = (item + "Embedded") 
deviceImport = __import__(device) 

with open("list_of_devices_currently_active.txt", "a+") as myfile: 
for item in devices: 
myfile.write(item + "\n") 

active_devices() 

def readFile(fname): 
print("List of devices currently active:") 
try: 
with open(fname, "r") as f: 
for item in f: 
print(item.rstrip("\n")) 
except: 
print("No devices added yet") 
readFile("list_of_devices_currently_active.txt") 

client = device() 
client.run() 

client.loop_start() 
print("Connected to broker") 
time.sleep(1) 
print("Subscribing to topic", "microscope/light_sheet_microscope/UI/states") 
client.subscribe("microscope/light_sheet_microscope/UI/states") 
client.loop_forever() 

mqtt.py 

import logging 
import paho.mqtt.client as mqtt 
import json 

class device(mqtt.Client): 
def on_connect(self, mqtt, obj, flags, rc): 
pass 

def on_message(self, mqtt, userdata, message): 
m_decode = str(message.payload.decode("utf-8")) 
print("message recieved= " + m_decode) 
# print("File which you want to import(with .py extension)") 
print("message topic=", message.topic) 
print("message qos=", message.qos) 
print("message retain flag=", message.retain) 
m_in = json.loads(m_decode) 

def run(self): 
self.connect("localhost", 1883, 60) 

GUI.py 

import paho.mqtt.client as mqtt 
import os 
import sys 
from PyQt5.QtWidgets import * 
from PyQt5.QtCore import * 
from PyQt5 import QtWidgets, uic 
from mqtt import * 
import json 
import time 

class MainWindow(QtWidgets.QMainWindow): 
def __init__(self,parent = None): 
QMainWindow.__init__(self) 
super(MainWindow, self).__init__(parent) 
self.mdi = QMdiArea() 
self.setCentralWidget(self.mdi) 

self.setMinimumSize(QSize(800, 600)) 
self.setWindowTitle("PyQt button example - 
pythonprogramminglanguage.com") 

client = device() 
client.run() 

client.loop_start() 
print("Connected to broker") 
time.sleep(1) 
print("Subscribing to topic", 
"microscope/light_sheet_microscope/UI/devices") 
client.subscribe("microscope/light_sheet_microscope/UI/devices") 
print("Publishing message to topic", 
"microscope/light_sheet_microscope/UI/devices") 
client.publish("microscope/light_sheet_microscope/UI/devices", 
json.dumps({"type": "system", "payload":{"cmd": "get all devices"}}, indent=2)) 
time.sleep(1) 

pybutton = QPushButton('Add device', self) 

pybutton.clicked.connect(self.importbutton) 

pybutton.move(100, 400) 
pybutton.resize(150, 32) 

self.combo = QComboBox(self) 
self.combo.move(100,350) 
self.combo.resize(100, 32) 

def readFile(fname): 
try: 
with open(fname, "r") as f: 
for item in f: 
self.combo.addItem(item) 
except: 
print("No devices active") 
readFile("list_of_devices_currently_active.txt") 

def importbutton(self): 
client = device()

Re: Recursive method in class

2019-09-27 Thread Jan van den Broek
On 2019-09-27, ast  wrote:
> Is it feasible to define a recursive method in a class ?
> (I don't need it, it's just a trial)
>
> Here are failing codes:
>
>
> class Test:
>  def fib(self, n):
>  if n < 2: return n
>  return fib(self, n-2) + fib(self, n-1)
  self.fib(...)

[Schnipp]

-- 
Jan v/d Broek
balgl...@dds.nl
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Recursive method in class

2019-09-27 Thread Rhodri James

On 27/09/2019 12:54, ast wrote:

Hello

Is it feasible to define a recursive method in a class ?
(I don't need it, it's just a trial)

Here are failing codes:


class Test:
     def fib(self, n):
     if n < 2: return n
     return fib(self, n-2) + fib(self, n-1)


Try self.fib(...) instead of fib(self, ...) both times.

--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


Help to understand the data structure

2019-09-27 Thread Mohan L
Hi All,

I am using get_devices_list method from this module:
https://github.com/Tufin/pytos/blob/master/pytos/securetrack/helpers.py.
Here is my two like code and output looks like:
https://pastebin.com/K9KBeqYL


I am not able to manage to further loop the data to print below output:


devicename1 10

devicename2 11

devicename3 12


I spend quit some time still not able to figure out how to parse. Can some
one through some light on how to phrase it.


--
Thanks & Regards
Mohan L
-- 
https://mail.python.org/mailman/listinfo/python-list


Generate simple image on a standalone Raspberrry Pi

2019-09-27 Thread Roy Hann
I am designing a mobile application to run on a Raspberry Pi 3 model B.
It will not have any Internet access. I need to generate a static image
consisting of a simple arc representing (say) a speedometer or a
pressure gauge. The image will need to be regenerated every 5 seconds.
The image must be displayed in a web browser (served by gunicorn
running on the Pi). I prefer it to be a PNG but that is only a
preference.

Plotly is amazing but big and slow. Pygal looked acceptable but
Internet access is required to render the SVG. 

Has anyone any suggestion for a lightweight solution? 

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


Re: Generate simple image on a standalone Raspberrry Pi

2019-09-27 Thread Thomas Jollans
On 27/09/2019 14.43, Roy Hann wrote:
> I am designing a mobile application to run on a Raspberry Pi 3 model B.
> It will not have any Internet access. I need to generate a static image
> consisting of a simple arc representing (say) a speedometer or a
> pressure gauge. The image will need to be regenerated every 5 seconds.
> The image must be displayed in a web browser (served by gunicorn
> running on the Pi). I prefer it to be a PNG but that is only a
> preference.
>
> Plotly is amazing but big and slow. Pygal looked acceptable but
> Internet access is required to render the SVG. 

There's always matplotlib.

Depending on how simple it needs to be, pillow might do the trick.

>
> Has anyone any suggestion for a lightweight solution? 
>
> Roy

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


Re: Help to understand the data structure

2019-09-27 Thread Mohan L
Hi All,

Please ignore it, I was able to figure out it.

for dev in devlist:
print (dev.name, dev.id)



--
Thanks & Regards
Mohan L




On Fri, Sep 27, 2019 at 8:41 PM Mohan L  wrote:

> Hi All,
>
> I am using get_devices_list method from this module:
> https://github.com/Tufin/pytos/blob/master/pytos/securetrack/helpers.py.
> Here is my two like code and output looks like:
> https://pastebin.com/K9KBeqYL
>
>
> I am not able to manage to further loop the data to print below output:
>
>
> devicename1 10
>
> devicename2 11
>
> devicename3 12
>
>
> I spend quit some time still not able to figure out how to parse. Can some
> one through some light on how to phrase it.
>
>
> --
> Thanks & Regards
> Mohan L
>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Help Wanted for the error

2019-09-27 Thread tommy yama
Hi ,

Has anyone seen similar errors previously?
I just encountered the error below and need to fix asap.

File
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/google/protobuf/descriptor_pool.py",
line 175, in _CheckConflictRegister

raise TypeError(error_msg)

TypeError: Conflict register for file "shared/mempool_status.proto":
mempool.Valid is already defined in file "mempool_status.proto". Please fix
the conflict by adding package name on the proto file, or use different
name for the duplication.


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


Re: Recursive method in class

2019-09-27 Thread Dan Sommers

On 9/27/19 7:54 AM, ast wrote:

Hello

Is it feasible to define a recursive method in a class ?
(I don't need it, it's just a trial)

Here are failing codes:


class Test:
  def fib(self, n):
  if n < 2: return n
  return fib(self, n-2) + fib(self, n-1)


return self.fib(n - 2) + self.fib(n - 1)

(1) This is a horribly ineffective way to compute Fibonacci
numbers, but that's not immediately relevant.

(2) Recursive instance methods only make sense when there's
some sort of state being maintained, which in this case there
is not.  But that's also not immediately relevant.
--
https://mail.python.org/mailman/listinfo/python-list


itertools query

2019-09-27 Thread Pradeep Patra
Hi all,

I have written a small program to generate all the combinations of a and b
of the array. I want (6,7) tuple also included. Can anybody suggest what
change I should make to get 6,7 included in my output? Any suggestions


 Output:
[(5,), (6,), (5, 6), (7,), (8,), (7, 8)]

from itertools import chain, combinations

a = [5,6]
b = [7,8]
ar=[]
br=[]

def all_subsets(ss):
return chain(*map(lambda x: combinations(ss, x), range(1, len(ss)+1)))

for subset in all_subsets(a):
print(subset)
ar.append(subset)

for subset in all_subsets(b):
print(subset)
br.append(subset)

fr=ar+br
print(fr)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: itertools query

2019-09-27 Thread Peter Otten
Pradeep Patra wrote:

> Hi all,
> 
> I have written a small program to generate all the combinations of a and b
> of the array. I want (6,7) tuple also included. Can anybody suggest what
> change I should make to get 6,7 included in my output? Any suggestions

The spec is not clear to me. If you don't care about the source list you can 
use

list(all_subsets(a + b))

but that will include many more combinations, including those consisting of 
three or four elements.

>  Output:
> [(5,), (6,), (5, 6), (7,), (8,), (7, 8)]
> 
> from itertools import chain, combinations
> 
> a = [5,6]
> b = [7,8]
> ar=[]
> br=[]
> 
> def all_subsets(ss):
> return chain(*map(lambda x: combinations(ss, x), range(1, len(ss)+1)))
> 
> for subset in all_subsets(a):
> print(subset)
> ar.append(subset)
> 
> for subset in all_subsets(b):
> print(subset)
> br.append(subset)
> 
> fr=ar+br
> print(fr)


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


Re: Angular distribution rose diagram in Python

2019-09-27 Thread Peter Pearson
On Fri, 27 Sep 2019 02:13:31 -0700 (PDT), Madhavan Bomidi wrote:
>
> Can someone help me to make python code (with some arbitrary data) for
> the angular distribution rose diagram as shown in figure 7 in the
> paper accessible through the web-link:
>
> https://www.nat-hazards-earth-syst-sci.net/17/1425/2017/nhess-17-1425-2017.pdf

Googling "matplotlib rose diagram" (without the quotation marks)
produced some promising results.  This one even has sample code:

   http://geologyandpython.com/structural_geology.html

I'm no graphics expert, but Matplotlib generally does the job for me.

-- 
To email me, substitute nowhere->runbox, invalid->com.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-27 Thread RobH

On 27/09/2019 15:28, Dennis Lee Bieber wrote:

On Fri, 27 Sep 2019 10:48:29 +0100, RobH  declaimed the
following:


Ok, the adafruit_character_lcd is in the same directory as yours, and so
is Blinka and Purio. It seems to be a bit of a long path to type to get
to the Adafruit_Charlcd directory, but is there a shortcut way of
getting to the said directory.



Other than to examine the source code of the library you have no need
to specify the directory... Within a Python script, a plain "import" should
work.

pi@raspberrypi:~$ python3
Python 3.7.3 (default, Apr  3 2019, 05:39:12)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

import adafruit_blinka
import adafruit_character_lcd as acl
dir(acl)

['__doc__', '__file__', '__loader__', '__name__', '__package__',
'__path__', '__spec__']

help(acl)



Help on package adafruit_character_lcd:

NAME
 adafruit_character_lcd

PACKAGE CONTENTS
 character_lcd
 character_lcd_i2c
 character_lcd_rgb_i2c
 character_lcd_spi

FILE
 (built-in)

(END)

from adafruit_character_lcd import character_lcd as cl
help(cl)

Help on module adafruit_character_lcd.character_lcd in
adafruit_character_lcd:

NAME
 adafruit_character_lcd.character_lcd

DESCRIPTION
 `adafruit_character_lcd.character_lcd`
 

 Module for interfacing with monochromatic character LCDs

 * Author(s): Kattni Rembor, Brent Rubell, Asher Lieber,
   Tony DiCola (original python charLCD library)

 Implementation Notes
 

 **Hardware:**

 "* `Adafruit Character LCDs `_"

 **Software and Dependencies:**

 * Adafruit CircuitPython firmware:
   https://github.com/adafruit/circuitpython/releases
 * Adafruit's Bus Device library (when using I2C/SPI):
   https://github.com/adafruit/Adafruit_CircuitPython_BusDevice

CLASSES
{AND MUCH MORE}




Thanks for all that information, but first of all using just import 
adafruit blinka did not work as it returned bas: import: command not found.


I should say that this is on a raspberry pi zero w, if it makes any 
difference.

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


Re: Generate simple image on a standalone Raspberrry Pi

2019-09-27 Thread Eli the Bearded
In comp.lang.python, Roy Hann   wrote:
> I am designing a mobile application to run on a Raspberry Pi 3 model B.
> It will not have any Internet access. I need to generate a static image
> consisting of a simple arc representing (say) a speedometer or a
> pressure gauge. The image will need to be regenerated every 5 seconds.
> The image must be displayed in a web browser (served by gunicorn
> running on the Pi). I prefer it to be a PNG but that is only a
> preference.

The browser can probably display SVG. So generating that may be easier.
Is the browser running on the same system? You say no "Internet access",
but that's not the same as "no network access". A browser running on a
different local system might have more CPU oomph to handle the "SVG to
bitmap for display" step.

I've used libpng from C and chunky_png from ruby and not found PNG
generation too onerous. That makes me think pypng wouldn't be bad
either. For the case of a speedometer / pressure gauge you can likely
have a blank gauge file you read in each time through the loop and then
only write the changes needed (eg, the needle).

Alternatively the guage could be a static image in the browser with an
overlaid dynamic needle image using a transparent background. The PNG
format will handle that easily.

Elijah
--
thinks there are a lot of unstated parts to this problem
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: itertools query

2019-09-27 Thread Piet van Oostrum
Pradeep Patra  writes:

> Hi all,
>
> I have written a small program to generate all the combinations of a and b
> of the array. I want (6,7) tuple also included. Can anybody suggest what
> change I should make to get 6,7 included in my output? Any suggestions
>

Why (6,7)? What about (5,7), (5,8) and (6,8)?
-- 
Piet van Oostrum 
WWW: http://piet.vanoostrum.org/
PGP key: [8DAE142BE17999C4]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PIP question

2019-09-27 Thread Gisle Vanem

dieter wrote:


directory with some possible leftovers. It there a connection
between this mysterious '-ip' package and this directory?


This is possible. A so called "distribution" can install
packages of a different name (for example, the distribution "Zope"
installs (among others) a package "ZPublisher"). In addition, the
actual installation typically has lost metadata information (e.g.
the version number). Therefore, "pip" may use "*.dist-info" or
"*.egg-info" directories to provide this metadata. Look into those
directories to find out which packages are installed for the
corresponding distribution. You can then check whether those packages
are truely available (and if not delete the *-info* directory).


Thanks for this info.

After deleting the
 f:\programfiler\python36\lib\site-packages\~ip-19.1.1.dist-info
directory and running my script again, the "-ip" is gone.

All this *.dist-info stuff is alien stuff to me, but I guess
'pip install --upgrade' uses these?

BTW, there is no command 'pip uninstall --orphans'. Any
other tool that does the same?

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


Re: itertools query

2019-09-27 Thread Pradeep Patra
I don't need other combination except 6,7

On Saturday, September 28, 2019, Piet van Oostrum 
wrote:

> Pradeep Patra  writes:
>
> > Hi all,
> >
> > I have written a small program to generate all the combinations of a and
> b
> > of the array. I want (6,7) tuple also included. Can anybody suggest what
> > change I should make to get 6,7 included in my output? Any suggestions
> >
>
> Why (6,7)? What about (5,7), (5,8) and (6,8)?
> --
> Piet van Oostrum 
> WWW: http://piet.vanoostrum.org/
> PGP key: [8DAE142BE17999C4]
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PIP question

2019-09-27 Thread dieter
Gisle Vanem  writes:
> ...
> All this *.dist-info stuff is alien stuff to me, but I guess
> 'pip install --upgrade' uses these?

Most of "pip" is using this. They contain important meta information
(e.g. version number, dependencies, overview information, ...)
about a distribution not directly used by Python.

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


Re: itertools query

2019-09-27 Thread Peter Otten
> Pradeep Patra wrote:

> My idea is to include the last element of array a and first element of 
second array b  in the final array.

fr.append((a[-1], b[0]))

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