Modules or Package for my application
Dear developers,
I am creating application (originally written in perl)
which will take care about replication from one system to the another system
over command rsync. It will simulate High-availability solution.
The application will contains main module called like ha.py
and another modules will have names Replication.py, Trace.py, Misc.py,
Procs.py, Constants.py, Lan.py, Display.py
My questions are:
1) When I would like to make a global logging to the one file is it enough to
do that like
TRACE='/var/ha/log/sso_trace.log'
logger = logging.getLogger('sso')
hdrl = logging.FileHandler(TRACE)
formatter = logging.Formatter('%{asctime}s %{levelname}s %{message}s')
hdrl.setFormatter(formatter)
logger.addHandler(hdrl)
logger.setLevel(logging.WARNING)
and make for them one module or how to solve that?
How to call that logger from all modules / packages?
Is it necessary to create alone module?
2) Is it package necessary or simply modules are enough
- Replication.py will take care about alone replication
- Procs.py will take care about some processes
- Constants.py will take care about definition of global constants
- Lan.py will take care about LAN definition
- Dipslay.py will take care about showing screen (GUI or text_based)
3) How / where to define global variables?
best regards
Petr
--
http://mail.python.org/mailman/listinfo/python-list
What's wrong with this code?
I'm totally confused by this code: Code: > a = None > b = None > c = None > d = None > x = [[a,b], > [c,d]] > e,f = x[1] > print e,f > c = 1 > d = 2 > print e,f > e = 1 > f = 2 > print c,d > > Output: None None > None None > 1 2 > I'm expecting the code as: > None None > 1 2 > 1 2 > > What's wrong? And this question made my GUI program totally out of control. Thanks[?] <<338.gif>>-- http://mail.python.org/mailman/listinfo/python-list
virtualenv and ubuntu
Hi there, Sorry if the question is naive, I am on Ubuntu 16.04 with Python 3.5.2, now I want to use virtualenv, I noticed there are two ways to get virtualenv installed: 1) do "sudo apt-get install virtualenv" 2) do "pip3 install virtualenv" What is the preferred way to install virtualenv? Thanks, Stone -- https://mail.python.org/mailman/listinfo/python-list
Re: virtualenv and ubuntu
On Tuesday, August 28, 2018 at 8:00:17 AM UTC-7, Matt Ruffalo wrote: > On 2018-08-28 07:26, [email protected] wrote: > > Hi there, > > > > Sorry if the question is naive, I am on Ubuntu 16.04 with Python 3.5.2, now > > I want to use virtualenv, I noticed there are two ways to get virtualenv > > installed: > > > > 1) do "sudo apt-get install virtualenv" > > 2) do "pip3 install virtualenv" > > > > What is the preferred way to install virtualenv? > > > > Thanks, > > Stone > > Hi Stone- > > The 'virtualenv' tool is superseded in Python 3.3+ by the 'venv' module > in the standard library. > > Ubuntu 16.04 does not have this installed by default; you can install it > with 'sudo apt-get install python3-venv'. After that, you can create a > virtual environment with 'python3 -m venv'. > > MMR... Hi Kunal and Matt, thanks for the help, really appreciated! - Stone -- https://mail.python.org/mailman/listinfo/python-list
Shall I worry about python2/3 compatibility when using library?
Hi there, I think the fact is: - There are still considerable amount of people still using python2 - Python2 user will eventually upgrade to python3 So any library not written in a compatible way will either break now for python2 user, or will break in the future for python3 user. So I suppose all library developer are writing compatible code, is that a fair assumption? Thanks, Stone -- https://mail.python.org/mailman/listinfo/python-list
Re: Shall I worry about python2/3 compatibility when using library?
On Thursday, August 30, 2018 at 10:19:34 PM UTC-7, Terry Reedy wrote: > On 8/30/2018 10:27 PM, Stone Zhong wrote: > > Hi there, > > > > I think the fact is: > > - There are still considerable amount of people still using python2 > > - Python2 user will eventually upgrade to python3 > > > > So any library not written in a compatible way will either break now for > > python2 user, or will break in the future for python3 user. So I suppose > > all library developer are writing compatible code, is that a fair > > assumption? > > No. Many people write new libraries only for recent version of Python > 3. Many people who have written Python 2 and 3 compatible libraries, or > Python 2 and Python 3 versions of of their library, have or will drop > Python 2 support for enhancements and even bugfixes for their library. > > That said, some people will continue to use existing python 2 code for a > decade or more. > > -- > Terry Jan Reedy Thanks for the reply Terry. Got it. So some people main separate libraries for python2 and python3 (although this way it may have extra cost), and may eventually drop support for python2 lib or may not even have library for python2. Thanks, Stone -- https://mail.python.org/mailman/listinfo/python-list
customer compare in assertEqual
Hi There, Now I want to make sure my code calls a function foo with an object t, however, foo.assert_called_once_with(t) does not work, since t is a model object and the code may load a different copy of t, so what I really want to test is "It calls foo with t where t.id equals real_t.id, is there a way to do that in python unit test? Thanks, Stone -- https://mail.python.org/mailman/listinfo/python-list
Re: customer compare in assertEqual
On Monday, October 29, 2018 at 5:29:11 PM UTC-7, Stone Zhong wrote: > Hi There, > > Now I want to make sure my code calls a function foo with an object t, > however, foo.assert_called_once_with(t) does not work, since t is a model > object and the code may load a different copy of t, so what I really want to > test is "It calls foo with t where t.id equals real_t.id, is there a way to > do that in python unit test? > > Thanks, > Stone Tried addTypeEqualityFunc and it does not seems help. -- https://mail.python.org/mailman/listinfo/python-list
Re: customer compare in assertEqual
On Monday, October 29, 2018 at 5:29:11 PM UTC-7, Stone Zhong wrote: > Hi There, > > Now I want to make sure my code calls a function foo with an object t, > however, foo.assert_called_once_with(t) does not work, since t is a model > object and the code may load a different copy of t, so what I really want to > test is "It calls foo with t where t.id equals real_t.id, is there a way to > do that in python unit test? > > Thanks, > Stone Thanks Peter, yeah, redefine the __eq__ works well. - Stone -- https://mail.python.org/mailman/listinfo/python-list
Installing Python 2.7 for all users on SLES 11
I installed Python 2.7 on SLES 11 box that previously was running Python 2.6. To do so I used a script described in this post (http://stackoverflow.com/a/11371726/135946) and run it as a root user. Everything went well but when it was done I discovered few issues: 1. No symbolic links were created and no path updated so I had to manually update the path to link to the new installation bin directory /opt/python2.7/bin 2. Everything runs good until I switch from root to the normal user at which point Python shell runs but some modules I installed such as PyYAML are missing. Again, these are OK when I run Python as root 3. As a regular user I'm not able to run pip, easy_install and wheel. For pip I get "ImportError: No module named pkg_resources" This question is also posted to Stackoverflow here: http://stackoverflow.com/q/38749809/135946 -- https://mail.python.org/mailman/listinfo/python-list
Re: Installing Python 2.7 for all users on SLES 11
On Thursday, August 4, 2016 at 8:54:35 PM UTC-7, Bo Stone wrote: > I installed Python 2.7 on SLES 11 box that previously was running Python 2.6. > To do so I used a script described in this post > (http://stackoverflow.com/a/11371726/135946) and run it as a root user. > Everything went well but when it was done I discovered few issues: > > 1. No symbolic links were created and no path updated so I had to manually > update the path to link to the new installation bin directory > /opt/python2.7/bin > 2. Everything runs good until I switch from root to the normal user at which > point Python shell runs but some modules I installed such as PyYAML are > missing. Again, these are OK when I run Python as root > 3. As a regular user I'm not able to run pip, easy_install and wheel. For pip > I get "ImportError: No module named pkg_resources" > > This question is also posted to Stackoverflow here: > http://stackoverflow.com/q/38749809/135946 The Stackoverflow question has now 100 points bounty -- https://mail.python.org/mailman/listinfo/python-list
ImportError: cannot import name certificate_transparency
Hi, My program depend on package oci, I am using the following command to install it: pip install oci Everything works perfect in virtualenv (I am still using python 2.7.x) Now I am creating a zip file from the libraries: pip install oci -t ~/temp/oci cd ~/temp/oci zip -r ~/temp/oci.zip . Test A) PYTHONPATH=~/temp/oci myapp.py Test B) PYTHONPATH=~/temp/oci.zip myapp.py Test A) works fine and Test B) failed with error "ImportError: cannot import name certificate_transparency" It seems we have some so file there: ./cryptography/hazmat/bindings/_padding.so ./cryptography/hazmat/bindings/_openssl.so ./cryptography/hazmat/bindings/_constant_time.so ./_cffi_backend.so I also tested below: mytest.py: ... from cryptography.hazmat.bindings._constant_time import lib PYTHONPATH=~/temp/oci.zip mytest.py I end up with error "ImportError: No module named _constant_time" So my guess is, package with shared lib (.so files) cannot be put into zip file, is it a bug in python zipimport? The reason I have to use a zip file is, I need it in a spark job, I cannot do "virtualenv" in pyspark, have to use --py-files to pass the zip file for all dependent packages. Thanks, Stone -- https://mail.python.org/mailman/listinfo/python-list
Re: ImportError: cannot import name certificate_transparency
On Thursday, January 17, 2019 at 12:10:51 AM UTC-8, Stone Zhong wrote: > Hi, > > My program depend on package oci, I am using the following command to install > it: > pip install oci > > Everything works perfect in virtualenv (I am still using python 2.7.x) > > Now I am creating a zip file from the libraries: > > pip install oci -t ~/temp/oci > cd ~/temp/oci > zip -r ~/temp/oci.zip . > > Test A) PYTHONPATH=~/temp/oci myapp.py > Test B) PYTHONPATH=~/temp/oci.zip myapp.py > > Test A) works fine and Test B) failed with error "ImportError: cannot import > name certificate_transparency" > > It seems we have some so file there: > ./cryptography/hazmat/bindings/_padding.so > ./cryptography/hazmat/bindings/_openssl.so > ./cryptography/hazmat/bindings/_constant_time.so > ./_cffi_backend.so > > I also tested below: > > mytest.py: > ... > from cryptography.hazmat.bindings._constant_time import lib > > PYTHONPATH=~/temp/oci.zip mytest.py > > I end up with error "ImportError: No module named _constant_time" > > So my guess is, package with shared lib (.so files) cannot be put into zip > file, is it a bug in python zipimport? > > The reason I have to use a zip file is, I need it in a spark job, I cannot do > "virtualenv" in pyspark, have to use --py-files to pass the zip file for all > dependent packages. > > Thanks, > Stone ok, found the doc @ https://docs.python.org/3/library/zipimport.html import of dynamic modules (.pyd, .so) is disallowed. So it is not a bug. -- https://mail.python.org/mailman/listinfo/python-list
Manipulating large blobs in Python
I'm working on a module that will manipulate large blobs. I'm using a C dll to allocate big blocks of memory, using PyMem_Malloc, which is working quite well up until I try to manipulate a blob that exhausts Python's heap. I'm guessing that to increase the heapsize, I'm going to have to recompile python... (??) Am I on the right track? If so, can you steer me toward some instructions on how to do that compile? I'm a command-line make kind of dude, and I don't see any of that kind of stuff in the source distribution. I see .vcproj xml-ish files... do I need some version of visual studio ide to do the windows compile? It'd be great if there was some way to increase the heapsize without all that bother :) Tim Stone -- http://mail.python.org/mailman/listinfo/python-list
request for guidance
greetings I am a novice who is really interested in contributing to Python projects. How and where do I begin? thanking you in anticipation -- https://mail.python.org/mailman/listinfo/python-list
Re: request for guidance
hello! thanks a ton for your warm response. I know the basics of python with some modules like pickle, urllib, re. Its kind of basic I know. but it gotta start somewhere and I really want to have real world experience. thanks jennifer On Fri, Dec 13, 2013 at 10:45 AM, jennifer stone wrote: > greetings > I am a novice who is really interested in contributing to Python projects. > How and where do I begin? > thanking you in anticipation > -- https://mail.python.org/mailman/listinfo/python-list
Re: bicycle repair man help
On Jun 23, 2007, at 2:24 PM, Rustom Mody wrote: > Does someone know that when using bicycle repair man to refactor > python code what exactly extract local variable means? I don't know about bicycle repair main, but in general 'extract local variable' means to make a change like this: self.method_call(1, ) to value = self.method_call(1, value) i.e, it takes an expression, assigns it to a variable name (which is specified by the user) and then uses that variable name in place of the expression. I would expect that you need to select the expression to be substituted for the refactoring to work. I hope this helps, Kathy Van Stone [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: What was that web interaction library called again?
So does anyone know of any equivalent library for testing RESTful web services. In particular it needs to be able to handle more than 'GET' or "POST" http calls. -Kathy Van Stone [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: unittest for threading function always failed...
If all you are doing is testing that run() works correctly, you could probably also get away with just calling run() directly instead of also implicitly testing the Thread class as well. -Kathy -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating a multi-tier client/server application
Greetings, I somehow missed some of this thread, but I believe you left a note saying that you were not able to do Extreme Programming. However, based on the description of the size of the project and the size of the development team (is there any more than you?) I would recommend you consider the following agile techniques: 1. Incremental development 2. Automated testing 3. Continuous integration I think 1 and 3 are important in giving you a continuously working system, along with a working system you can use for feedback during the development process. Automated testing would support 1 and 3 and keep you from having to do a lot of manual testing. Wikipedia describes most of those terms. Also think about having acceptance tests that someone besides you can verify match the specifications. Lastly do use the fact that you are (presumably) close to some of your customers to use face time for additional communication usually needed beyond specs. I hope this helps. It sounds like a useful project. Kathy Van Stone [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
