python 3.7 - I try to close the thread without closing the GUI is it possible?

2018-09-14 Thread alon . najman
python 3.7 - I try to close the thread without closing the GUI is it possible? 

here is my code, sorry I'm am new with python and generally with code XD .

thanks all



# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'AlonStockMarket.ui'
#
# Created by: PyQt5 UI code generator 5.11.2
#
# WARNING! All changes made in this file will be lost!
import time
import sys
import requests
from lxml import html
import requests
import urllib.request, urllib.error, urllib.parse
import _thread
from PyQt5 import QtCore, QtGui, QtWidgets


from multiprocessing import Pool

global flag



import threading
import time

exitFlag = 0

class myThread (threading.Thread):
   def __init__(self, threadID, name, counter):
  threading.Thread.__init__(self)
  self.threadID = threadID
  self.name = name
  self.counter = counter
   def run(self):
  print ("Starting " + self.name)
  print_time(self.name, self.counter, 5)
  print ("Exiting " + self.name)

def print_time(threadName, delay, counter):
  print("hello, world")
  while True:
time.sleep(15)
f=open("flag.txt", "r")
if f.mode == 'r': 
flag =f.read()
timeHour = int(time.strftime('%H'))
print("keep alive")
print (time.strftime('%H:%M:%S'))
while ((timeHour>16) and (timeHour<23)):
print(time.strftime('%H:%M:%S'))
price=get_quote('evok')
time.sleep(5)
if flag!=time.strftime("%d/%m/%Y") and price>4:
 print ("send SMS")
 import requests
 requests.post('https://textbelt.com/text', {
 'phone': '+972546233257',
 'message': "Hi Alon Najman,EVOK value: "+Price,
 'key': 'secret',
 }) 
 #write to file
 with open("flag.txt", "w") as text_file:
 text_file.write(format(time.strftime("%d/%m/%Y")))
 #read from file
 f=open("flag.txt", "r")
 if f.mode == 'r': 
   flag =f.read()  

# Create new threads
thread1 = myThread(1, "Thread-1", 1)


# Start new Threads






def get_quote(str):
url="https://api.iextrading.com/1.0/stock/"+str+"/price";
resource = urllib.request.urlopen(url)
content =  resource.read().decode(resource.headers.get_content_charset())
print (content)
content=float(content)
return content


class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(666, 571)
self.radioButton = QtWidgets.QRadioButton(Dialog)
self.radioButton.setGeometry(QtCore.QRect(80, 190, 191, 24))
font = QtGui.QFont()
font.setPointSize(14)
self.radioButton.setFont(font)
self.radioButton.setObjectName("radioButton")
self.buttonGroup_2 = QtWidgets.QButtonGroup(Dialog)
self.buttonGroup_2.setObjectName("buttonGroup_2")
self.buttonGroup_2.addButton(self.radioButton)
self.checkBox = QtWidgets.QCheckBox(Dialog)
self.checkBox.setGeometry(QtCore.QRect(290, 450, 131, 17))
font = QtGui.QFont()
font.setPointSize(14)
self.checkBox.setFont(font)
self.checkBox.setObjectName("checkBox")
self.checkBox_2 = QtWidgets.QCheckBox(Dialog)
self.checkBox_2.setGeometry(QtCore.QRect(290, 480, 141, 17))
font = QtGui.QFont()
font.setPointSize(14)
self.checkBox_2.setFont(font)
self.checkBox_2.setObjectName("checkBox_2")
self.textEdit = QtWidgets.QTextEdit(Dialog)
self.textEdit.setGeometry(QtCore.QRect(130, 20, 321, 41))
self.textEdit.setObjectName("textEdit")
self.radioButton_2 = QtWidgets.QRadioButton(Dialog)
self.radioButton_2.setGeometry(QtCore.QRect(300, 190, 186, 24))
font = QtGui.QFont()
font.setPointSize(14)
self.radioButton_2.setFont(font)
self.radioButton_2.setObjectName("radioButton_2")
self.buttonGroup_2.addButton(self.radioButton_2)
self.pushButton = QtWidgets.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(60, 460, 72, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.pushButton.setFont(font)
self.pushButton.setObjectName("pushButton")
self.radioButton_3 = QtWidgets.QRadioButton(Dialog)
self.radioButton_3.setGeometry(QtCore.QRect(80, 250, 191, 24))
font = QtGui.QFont()
font.setPointSize(14)
self.radioButton_3.setFont(font)
self.radioButton_3.setObjectName("radioButton_3")
self.buttonGroup = QtWidgets.QButtonGroup(Dialog)
self.buttonGroup.setObjectName("buttonGroup")
self.buttonGroup.addButton(self.radioButton_3)
self.radioButton_4 = QtWidgets.QRadioButton(Dialog)
   

Re: Trying to use threading.local()

2018-09-14 Thread Antoon Pardon
On 13-09-18 14:29, Chris Angelico wrote:
> "Preferred" doesn't exclude the possibility that alternatives are
> needed, though. For example, good luck making decimal.Decimal contexts
> work correctly without the help of thread-locals - there MIGHT be a
> way to do it, but even if there is, it sure won't be pretty.

Can you elaborate on that. Suppose I have two threads, one in which I need
a precision of 3 and the other in which I need a precision of 7. In what
circumstances is it needed to use threads-locals to accomplish this and
how do I accomplish this?

If I want my decimal code be usable with threads, how should I write it?

-- 
Antoon Pardon

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


Add header at top with email.message

2018-09-14 Thread Thomas Schneider
Hi,

the EmailMessage class of email.message provides the methods
add_header() and __setitem__() to add a header to a message.
add_header() effectively calls __setitem__(), which does
`self._headers.append(self.policy.header_store_parse(name, val))`.  This
inserts the header at the bottom.

It is, however, sometimes desired to insert a new header at the top of
an (existing) message.  This API doesn’t directly allow this.  In my
opinion, add_header() should have a flag at_top=False or similar, so
that one can get this behaviour (it’ll be a bit difficult with
__setitem__).  What do you think about this?  Is there a feasible way to
do this and change the library?  Should I post it somewhere where the
devs can hear it and suggest that?

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


Re: Trying to use threading.local()

2018-09-14 Thread Chris Angelico
On Fri, Sep 14, 2018 at 5:25 PM, Antoon Pardon  wrote:
> On 13-09-18 14:29, Chris Angelico wrote:
>> "Preferred" doesn't exclude the possibility that alternatives are
>> needed, though. For example, good luck making decimal.Decimal contexts
>> work correctly without the help of thread-locals - there MIGHT be a
>> way to do it, but even if there is, it sure won't be pretty.
>
> Can you elaborate on that. Suppose I have two threads, one in which I need
> a precision of 3 and the other in which I need a precision of 7. In what
> circumstances is it needed to use threads-locals to accomplish this and
> how do I accomplish this?
>
> If I want my decimal code be usable with threads, how should I write it?

Let's say both of those threads call the same function, which does this:

def f(x, y):
return x * 3 + y / 4

You can't pass a context as a parameter, so you have to set the
context externally. Which is done thus:

https://docs.python.org/3/library/decimal.html#decimal.setcontext

Note that this sets it *for the current thread*.

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


Re: Trying to use threading.local()

2018-09-14 Thread Thomas Jollans

On 14/09/18 10:29, Chris Angelico wrote:

On Fri, Sep 14, 2018 at 5:25 PM, Antoon Pardon  wrote:

On 13-09-18 14:29, Chris Angelico wrote:

"Preferred" doesn't exclude the possibility that alternatives are
needed, though. For example, good luck making decimal.Decimal contexts
work correctly without the help of thread-locals - there MIGHT be a
way to do it, but even if there is, it sure won't be pretty.

Can you elaborate on that. Suppose I have two threads, one in which I need
a precision of 3 and the other in which I need a precision of 7. In what
circumstances is it needed to use threads-locals to accomplish this and
how do I accomplish this?

If I want my decimal code be usable with threads, how should I write it?

Let's say both of those threads call the same function, which does this:

def f(x, y):
 return x * 3 + y / 4

You can't pass a context as a parameter, so you have to set the
context externally. Which is done thus:

https://docs.python.org/3/library/decimal.html#decimal.setcontext

Note that this sets it *for the current thread*.

ChrisA


Ideally use a context manager to manage your context: 
https://docs.python.org/3/library/decimal.html#decimal.localcontext


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


Re: Trying to use threading.local()

2018-09-14 Thread Chris Angelico
On Fri, Sep 14, 2018 at 6:34 PM, Thomas Jollans  wrote:
> On 14/09/18 10:29, Chris Angelico wrote:
>>
>> On Fri, Sep 14, 2018 at 5:25 PM, Antoon Pardon 
>> wrote:
>>>
>>> On 13-09-18 14:29, Chris Angelico wrote:

 "Preferred" doesn't exclude the possibility that alternatives are
 needed, though. For example, good luck making decimal.Decimal contexts
 work correctly without the help of thread-locals - there MIGHT be a
 way to do it, but even if there is, it sure won't be pretty.
>>>
>>> Can you elaborate on that. Suppose I have two threads, one in which I
>>> need
>>> a precision of 3 and the other in which I need a precision of 7. In what
>>> circumstances is it needed to use threads-locals to accomplish this and
>>> how do I accomplish this?
>>>
>>> If I want my decimal code be usable with threads, how should I write it?
>>
>> Let's say both of those threads call the same function, which does this:
>>
>> def f(x, y):
>>  return x * 3 + y / 4
>>
>> You can't pass a context as a parameter, so you have to set the
>> context externally. Which is done thus:
>>
>> https://docs.python.org/3/library/decimal.html#decimal.setcontext
>>
>> Note that this sets it *for the current thread*.
>>
>> ChrisA
>
>
> Ideally use a context manager to manage your context:
> https://docs.python.org/3/library/decimal.html#decimal.localcontext

Which is ALSO setting it "for the active thread", and (at least in the
pure-Python implementation of the decimal module) is implemented on
top of setcontext anyway. Actually, the context manager version
highlights the need for thread-locality even more; you expect
atomicity from it, and you'd be MAJORLY messed up if another thread
broke that.

BTW, to more specifically answer this question:

On Fri, Sep 14, 2018 at 5:25 PM, Antoon Pardon  wrote:
> If I want my decimal code be usable with threads, how should I write it?

Just write it in the most simple and obvious way. Don't even think
about contexts unless you need to, and if you do, don't concern
yourself with threads and contexts unless you are yourself creating
both of them. Even then, I believe decimal will DTRT by default in
most cases. Thread locals are the magic that makes this happen, but
you don't have to think about that magic usually.

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


Re: Trying to use threading.local()

2018-09-14 Thread Antoon Pardon
On 14-09-18 10:29, Chris Angelico wrote:
> On Fri, Sep 14, 2018 at 5:25 PM, Antoon Pardon  wrote:
>>
>> ... Suppose I have two threads, one in which I need
>> a precision of 3 and the other in which I need a precision of 7. In what
>> circumstances is it needed to use threads-locals to accomplish this and
>> how do I accomplish this?
>>
>> If I want my decimal code be usable with threads, how should I write it?
> Let's say both of those threads call the same function, which does this:
>
> def f(x, y):
> return x * 3 + y / 4
>
> You can't pass a context as a parameter, so you have to set the
> context externally. Which is done thus:
>
> https://docs.python.org/3/library/decimal.html#decimal.setcontext
>
> Note that this sets it *for the current thread*.

So, if I understand correctly, the threads-local information in this case is
part of the decimal implementation, so that the right context/precision is
used for the right thread.

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


Re: Trying to use threading.local()

2018-09-14 Thread Chris Angelico
On Fri, Sep 14, 2018 at 7:18 PM, Antoon Pardon  wrote:
> On 14-09-18 10:29, Chris Angelico wrote:
>> On Fri, Sep 14, 2018 at 5:25 PM, Antoon Pardon  wrote:
>>>
>>> ... Suppose I have two threads, one in which I need
>>> a precision of 3 and the other in which I need a precision of 7. In what
>>> circumstances is it needed to use threads-locals to accomplish this and
>>> how do I accomplish this?
>>>
>>> If I want my decimal code be usable with threads, how should I write it?
>> Let's say both of those threads call the same function, which does this:
>>
>> def f(x, y):
>> return x * 3 + y / 4
>>
>> You can't pass a context as a parameter, so you have to set the
>> context externally. Which is done thus:
>>
>> https://docs.python.org/3/library/decimal.html#decimal.setcontext
>>
>> Note that this sets it *for the current thread*.
>
> So, if I understand correctly, the threads-local information in this case is
> part of the decimal implementation, so that the right context/precision is
> used for the right thread.
>

Correct, though it's an exposed part of the API too, so it's not
"implementation detail" in the sense that it could be changed easily.

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


how to convert this psuedo code to python

2018-09-14 Thread Noel P. CUA
 compose your own octave script to calculate the machine
epsilon. Analyze the code.

epsilon = 1
DO
IF (epsilon+1<=1) EXIT
epsilon = epsilon/2
END DO
epsilon = 2 x epsilon

-- 

*This email and any files transmitted with it are confidential and 
intended solely for the use of the individual or entity to whom they are 
addressed. If you have received this email in error please notify the 
system manager . This message contains 
confidential information and is intended only for the individual named. *If 
you are not the named addressee you should not disseminate, distribute or 
copy this e-mail*. Please notify the sender immediately by e-mail if you 
have received this e-mail by mistake and delete this e-mail from your 
system. If you are not the intended recipient you are notified that 
disclosing, copying, distributing or taking any action in reliance on the 
contents of this information is strictly prohibited.*
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Looking for a Scrapy cheatsheet

2018-09-14 Thread Jim

On 09/14/2018 01:27 AM, Danyelle Davis wrote:

The one that sans provides seems pretty decent. Did you not like it?


What is sans? Do you have a url.

Thanks,  Jim


On Thu, Sep 13, 2018 at 4:05 PM Jim  wrote:


I'm in the process of learning Scrapy. I've read through the docs and a
couple of tutorials, but I am getting bogged down because I can't find a
page/table/chart that gives a nice concise overview of the available
commands and methods.

Googling hasn't found anything usable. So does anyone know of a
cheatsheet I can download.

Thanks,  Jim

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




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


Re: how to convert this psuedo code to python

2018-09-14 Thread Max Zettlmeißl via Python-list
On Fri, Sep 14, 2018 at 2:37 PM, Noel P. CUA  wrote:
>  compose your own octave script to calculate the machine
> epsilon. Analyze the code.
>
> epsilon = 1
> DO
> IF (epsilon+1<=1) EXIT
> epsilon = epsilon/2
> END DO
> epsilon = 2 x epsilon
>

epsilon = 1

while epsilon + 1 > 1:
epsilon = epsilon / 2.0

epsilon = 2 * epsilon


This will not work in Octave. But maybe it will help you in improving
your understanding of the solution.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help on PyList 3.7.0

2018-09-14 Thread Jason Qian via Python-list
Thanks a lot.

On Thu, Sep 13, 2018 at 5:24 PM, MRAB  wrote:

> On 2018-09-13 21:50, Jason Qian via Python-list wrote:
>
>> Hey,
>>
>> Need some help on PyList.
>>
>>
>> #get path
>> PyObject *path = PyObject_GetAttrString(sys, "path");
>>
>> #new user path
>> PyObject* newPath = PyUnicode_DecodeUTF8(userPath, strlen( userPath ),
>> errors);
>>
>> #append  newPath to path
>> PyList_Append(path, newPath);
>>
>> How to check if the newPath is already in the path ?
>>
>> So, If the path contains the newPath, I will not append the newpath.
>>
>>
>> Thanks for help
>>
>> A list is a sequence. Use PySequence_Contains.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Looking for a Scrapy cheatsheet

2018-09-14 Thread Jim

On 09/14/2018 08:15 AM, Jim wrote:

On 09/14/2018 01:27 AM, Danyelle Davis wrote:

The one that sans provides seems pretty decent. Did you not like it?


What is sans? Do you have a url.

Thanks,  Jim


Nevermind. I googled scrapy sans and I think we are talking about two 
different programs with the same name. I was inquiring about the web 
scraping program Scrapy. The one at SANS seems to be about penetration 
testing.


Regards,  Jim


On Thu, Sep 13, 2018 at 4:05 PM Jim  wrote:


I'm in the process of learning Scrapy. I've read through the docs and a
couple of tutorials, but I am getting bogged down because I can't find a
page/table/chart that gives a nice concise overview of the available
commands and methods.

Googling hasn't found anything usable. So does anyone know of a
cheatsheet I can download.

Thanks,  Jim

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







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


Re: Looking for a Scrapy cheatsheet

2018-09-14 Thread Joe Gulizia
I just goolged  for SANS Scrapy Cheatsheetthey have several


SANS.org


From: Python-list  on 
behalf of Jim 
Sent: Friday, September 14, 2018 8:15:05 AM
To: [email protected]
Subject: Re: Looking for a Scrapy cheatsheet

On 09/14/2018 01:27 AM, Danyelle Davis wrote:
> The one that sans provides seems pretty decent. Did you not like it?

What is sans? Do you have a url.

Thanks,  Jim

> On Thu, Sep 13, 2018 at 4:05 PM Jim  wrote:
>
>> I'm in the process of learning Scrapy. I've read through the docs and a
>> couple of tutorials, but I am getting bogged down because I can't find a
>> page/table/chart that gives a nice concise overview of the available
>> commands and methods.
>>
>> Googling hasn't found anything usable. So does anyone know of a
>> cheatsheet I can download.
>>
>> Thanks,  Jim
>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>


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


help me in python plssss!!!!

2018-09-14 Thread Noel P. CUA
 Calculate the true, relative and approximate errors, and  Relate the absolute 
relative approximate error to the number of significant digits.

epsilon = 1

while epsilon + 1 > 1:
epsilon = epsilon / 2.0

epsilon = 2 * epsilon

help me!

-- 

*This email and any files transmitted with it are confidential and 
intended solely for the use of the individual or entity to whom they are 
addressed. If you have received this email in error please notify the 
system manager . This message contains 
confidential information and is intended only for the individual named. *If 
you are not the named addressee you should not disseminate, distribute or 
copy this e-mail*. Please notify the sender immediately by e-mail if you 
have received this e-mail by mistake and delete this e-mail from your 
system. If you are not the intended recipient you are notified that 
disclosing, copying, distributing or taking any action in reliance on the 
contents of this information is strictly prohibited.*
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: help me in python plssss!!!!

2018-09-14 Thread Max Zettlmeißl via Python-list
On Fri, Sep 14, 2018 at 4:33 PM, Noel P. CUA  wrote:
>  Calculate the true, relative and approximate errors, and  Relate the 
> absolute relative approximate error to the number of significant digits.
>
> epsilon = 1
>
> while epsilon + 1 > 1:
> epsilon = epsilon / 2.0
>
> epsilon = 2 * epsilon
>
> help me!
>

This list is not here to solve every single step of what is
(presumably) your homework for you. Everything you present right here
is what I helped you with in "how to convert this psuedo code to
python".
You will have to at least try it yourself and to present your
approaches or at least ideas.

Additionally, [email protected] seems to be more fitting for the rather
basic level of the problems which you present.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fumbling with emacs + elpy + flake8

2018-09-14 Thread Toni Sissala
I'm on Ubuntu 16.04. I found out that flake8 did not play well with 
emacs if installed with --user option, nor when installed in a virtual 
environment. Didn't research any further, since I got it working with 
plain pip3 install flake8


Do you see any error messages?


Toni


On 13.9.2018 21:59, Martin Schöön wrote:

I am trying to set up emacs for Python coding on my secondary computer.
I follow these instructions but fail to make flake8 play with elpy:

https://realpython.com/emacs-the-best-python-editor/#elpy-python-development

I have done this some time in the past on my main computer and there it
works just fine. I have compared the set-up of this on the two computers
and fail to figure out why it works on one and not the other.

There are a couple of things that are not the same on the computers:

1) The secondary computer has a later version of emacs installed.

2) I used pip3 install --user flake8 on the secondary computer but on
the primary computer I think I left out the --user flag (not knowing
about it at the time) but I have added the path to .local/bin and
M-x elpy-config finds flake8 on both computers. Yet it does not
work on my secondary computer...

Any leads are greatly appreciated.

/Martin

PS Debian on both computers.



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


Image processing libraries in python

2018-09-14 Thread tejaswi
Hello everyone,
I was looking to work with images in python. I saw two packages
related to this, Pillow and scipy.ndimage.  I was wondering what
purposes each of these serve.
I've previously used matlab/octave's image processing facilities and
found them quite easy to work with, so is scipy the way to go in that
case.
Thank you,
Tejaswi D Prakash
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Image processing libraries in python

2018-09-14 Thread MRAB

On 2018-09-14 18:04, tejaswi wrote:

Hello everyone,
I was looking to work with images in python. I saw two packages
related to this, Pillow and scipy.ndimage.  I was wondering what
purposes each of these serve.
I've previously used matlab/octave's image processing facilities and
found them quite easy to work with, so is scipy the way to go in that
case.


Depending on that you want to do, there's also OpenCV.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Image processing libraries in python

2018-09-14 Thread Thomas Jollans

On 14/09/18 19:04, tejaswi wrote:

Hello everyone,
I was looking to work with images in python. I saw two packages
related to this, Pillow and scipy.ndimage.  I was wondering what
purposes each of these serve.
I've previously used matlab/octave's image processing facilities and
found them quite easy to work with, so is scipy the way to go in that
case.
Thank you,
Tejaswi D Prakash
Pillow is great for simple image processing. Converting between formats, 
resizing, cropping, rotating. simple filters - that kind of thing. The 
kind of thing you might otherwise do with GIMP, you might say.


For more in-depth image analysis, scipy.ndimage and scikit-image are 
your friends. Obviously they work better with the numpy/scipy ecosystem.


And, as MRAB points out, there's also OpenCV, which is fantastic for 
certain types of problems (have a look at the docs). For some fields 
(e.g. astronomy) there are also more specialized packages that may help.


In short, if you images are pictures, have a look at Pillow. If your 
images are data, have a look at scikit-image, scipy.ndimage, and maybe 
more specialized packages like OpenCV or astropy.


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


Re: Python for System Verilog testbench

2018-09-14 Thread Bobby
Hi George

WOW!  thanks for the reply and specially thanks for using the word 'BDD'. I
read the articles regarding BDD the whole day and understood the concepts.
Now will get this Pytest test framework with pytest bdd plugin. I found out
it follows this Gherkin syntax. Then I read about this Gherkin synatx. It
also looks good specially for Verilog. Maybe the syntax I was following
earlier is too complicated.

Some more questions regarding this:

- I read that there are other Python framweorks also
for BDD like 'behave'. What do you suggest as a beginner is Pytest-bdd is
easier or 'behave' ?

- If I am able to successfully map the requirements in pytest-bdd following
this Gherkins syntax, in the end what we get is Python code. To proceed
further, will I have to use Python to Verilog parser for the final Verilog
kind of structure?






On Friday, September 14, 2018, George Fischhof  wrote:
>
>
> Bobby  ezt írta (időpont: 2018. szept. 14., P
0:16):
>>
>> I have a very simple System Verilog (SV) adder as my DUT (device under
test). I would like to  generate a test bench for this DUT based on the
'requirements'. I wrote its  (DUT) functions in simple text as
'requirements' while following a particular syntax. Now through  the help
of grammar, I would like to give the requirement input to the grammar.
>>
>> Questions:
>>
>>  (1) Considering my end goal, i.e. to generate some particular parts
of
>>  SV testbench from requirements, any good python parser
available ?
>>
>>  (2) If I use python parser, will any kind of python scripting will
help me to generate the testbench in SV for my DUT ? My confusion at this
point is that most of all the literature I am reading suggests linguistic
techniques. Any non-linguistic technique ?
>>
>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>
> Hi,
> Perhaps you should check articles about BDD,  and you can use PyTest test
framework with pytest-bdd plugin
> __george__
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python for System Verilog testbench

2018-09-14 Thread Dale Marvin via Python-list

On 9/14/18 11:41 AM, Bobby wrote:

Hi George

WOW!  thanks for the reply and specially thanks for using the word 'BDD'. I
read the articles regarding BDD the whole day and understood the concepts.
Now will get this Pytest test framework with pytest bdd plugin. I found out
it follows this Gherkin syntax. Then I read about this Gherkin synatx. It
also looks good specially for Verilog. Maybe the syntax I was following
earlier is too complicated.

Some more questions regarding this:

- I read that there are other Python framweorks also
for BDD like 'behave'. What do you suggest as a beginner is Pytest-bdd is
easier or 'behave' ?

- If I am able to successfully map the requirements in pytest-bdd following
this Gherkins syntax, in the end what we get is Python code. To proceed
further, will I have to use Python to Verilog parser for the final Verilog
kind of structure?



Hi Bobby,
It's better to either bottom post, or inline your comments as the thread 
gets mangled in the archives.


There is MyHDL that may be of some use: 

"MyHDL turns Python into a hardware description and verification 
language, providing hardware engineers with the power of the Python 
ecosystem."


It supports synthesis from the Python RTL Models:


- Dale




On Friday, September 14, 2018, George Fischhof  wrote:



Bobby  ezt írta (időpont: 2018. szept. 14., P

0:16):


I have a very simple System Verilog (SV) adder as my DUT (device under

test). I would like to  generate a test bench for this DUT based on the
'requirements'. I wrote its  (DUT) functions in simple text as
'requirements' while following a particular syntax. Now through  the help
of grammar, I would like to give the requirement input to the grammar.


Questions:

  (1) Considering my end goal, i.e. to generate some particular parts

of

  SV testbench from requirements, any good python parser

available ?


  (2) If I use python parser, will any kind of python scripting will

help me to generate the testbench in SV for my DUT ? My confusion at this
point is that most of all the literature I am reading suggests linguistic
techniques. Any non-linguistic technique ?



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


Hi,
Perhaps you should check articles about BDD,  and you can use PyTest test

framework with pytest-bdd plugin

__george__



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


Re: python 3.7 - I try to close the thread without closing the GUI is it possible?

2018-09-14 Thread dieter
[email protected] writes:
> python 3.7 - I try to close the thread without closing the GUI is it 
> possible? 

I assume that with "close a thread" you mean "terminate a thread".

It is difficult to terminate a thread from the outside, because
on many platforms, there is no reliable way to terminate an
(operating system level) thread in a safe way.

The easiest thing would be that you prepare your thread to
terminate (on its own) when the outside world sets a flag
that it should terminate.

In Python 2, there has been a C level Python function
which allows to indicate to a thread that it should terminate.
It implements the approach from the previous paragraph but
at the Python interpreter level. It cannot stop a thread
if it is not executing Python code (but somewhere in a "C" extension).
Not sure, whether this function is available in Python 3.

It might be possible that you move the activity now done in a
thread into a process. Terminating a process is far easier
than terminating a thread.

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