Re: [melbourne-pug] Inserting images into MSSQL using Python

2014-01-19 Thread David Crisp
Dave,  Pil was just an example of the tools i had been playing with at the 
time I was trying to work out the DB insertts.



On Mon, 20 Jan 2014, Dave Collins wrote:


David,
What data type are using using in the database?

You should not need PIL to read or write data in from disk and put into
a database.

dave


On Mon, 2014-01-20 at 15:47 +1100, David Crisp wrote:

Using Python, What is the best method for reading a small PNG file from
disk then writing it to a MS SQL database (2008)   and then retrieiving
the binary data and writing it out to disk as a valid png file.

THis is for writing VERY small (700 byte) monocrhome PNG file to the
database.

The prefered Python MSSQL engine Im using is PYMSSQL.   its the one I have
used for the rest of the text so its the one I need to use for the binary
data.

I have fiddled with the PIL / PILLOW library

I think my problem is im looking in the wrong directions!

How do other people do this?
Regards,
David

___
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug



___
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug


___
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug


Re: [melbourne-pug] Question about adding members to list : hypothetical just for interest kind of question

2014-02-20 Thread David Crisp
Ahh :)I also meant to say that whilest the particular fields I am 
talking about in this question are the same,  data at the end of those 
rows is different,  and will be treated differently.


I really abstracted my query away from what I am actually trying to do 
exactly and more along the lines of how effiecient or ineficient I am 
doing things.


This particular SQL query was originally - before I optimised it for the 
person here working with it - returning upwards of 100,000 rows of data 
because it had been produced by sombody using the built in data join 
wizard in MSSQL Server Management Studio.  They would then post process it 
in code (various flavours of .net and C ) and come up with the results 
they were wanting...  The query I hand cut for them and tested now returns 
exactly the data they wish in just enough rows to contain it all.  No need 
to post process it as such.


Regards,
David



On Fri, 21 Feb 2014, Ben Finney wrote:


David Crisp dcr...@netspace.net.au writes:


In this case I am reading in data from a SQL database query(pymssql)


If you want to eliminate duplicates from your query, do so with ‘SELECT
DISTINCT’. Then you don't ever get the duplicate rows in the first place :-)

--
\  “Ocean, n. A body of water occupying about two-thirds of a |
 `\ world made for man — who has no gills.” —Ambrose Bierce, _The |
_o__)Devil's Dictionary_, 1906 |
Ben Finney

___
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug

___
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug


Re: [melbourne-pug] Any Python-gnuPG success on Windows 7 and Python 3.3

2014-05-27 Thread David Crisp

Hi Sam,

That.. That seems to have worked to the next stage! (it accepted it 
without chokeing) I tried all sorts of quoting but I didnt think if 
quoting like that! :)  Thank you.


I didnt want to try and mess with moving the executable to a more 
accessible location as I dont have the ability to do this in the 
production environemnt.


Regards,
David





On Tue, 27 May 2014, Sam Lai wrote:


Without looking at the source code, could you try double-quoting the path, e.g.

pathtobin = \C:\\Program Files (x86)\\GNU\\GnuPG\\pub\\GPG.exe\'

On 27 May 2014 13:52, David Crisp dcr...@netspace.net.au wrote:

Has anybody had any success getting Python-GnuPG working with Python3.3 on
Windows 7?

When I run it I get all sorts of errors that look likes its not really
likeing the way the arguments are handled.

It looks like the Argument / Attribute code isnt working properly. Before I
push this back at the authors I was just wanting to make sure I was using it
properly.

THe documentation SAYS it works with windows BUT it only provides Linux
examples.  So I MIGHT very well be implimenting it incorrectly.

Code:
import gnupg
pathtobin = C:\\Program Files (x86)\\GNU\\GnuPG\\pub\\GPG.exe
gpg = gnupg.GPG(gpgbinary = pathtobin, verbose = 'True')
print(gpg)

Errors:

C:\Python33\python.exe C:/Users/dcrisp/Documents/Python/origin/gpgdecrypt.py
C:\Program Files (x86)\GNU\GnuPG\pub\GPG.exe --status-fd 2 --no-tty
--version
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Traceback (most recent call last):
  File C:/Users/dcrisp/Documents/Python/origin/gpgdecrypt.py, line 12, in
module
gpg = gnupg.GPG(gpgbinary = pathtobin, verbose = 'True')
  File C:\Python33\lib\site-packages\gnupg.py, line 669, in __init__
result.stderr))
ValueError: Error invoking gpg: 1: 'C:\Program' is not recognized as an
internal or external command,
operable program or batch file.

It looks like the attribute / argument generation code isnt working
correctly.

Looks like the fault (if there is one) is around line 687 in gnupg.py. But
thats just a very rough guess and I have NO idea what to do to repair it.

Regards,
David

___
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug

___
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug


___
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug


[melbourne-pug] Python3 Soap Libraries Optionws

2014-05-28 Thread David Crisp

What SOAP modules have people used for client operations?

Currently I am using suds and I'm not convinced it works properly.

I am trying to interact with a usage monitor interface at Rackcorp.com

My code snippet im starting with is the following:

from suds.client import Client
url = 'http://api.rackcorp.net/api/soap/rcnetv123.wsdl'
client = Client(url)
print(client)

When I run that I get the following error:

suds.TypeNotFound: Type not found: '(Array,
http://schemas.xmlsoap.org/soap/encoding/, )'

A google of this error shows a work around  which doesnt work for me. 
and as this problem appears to be specific to SUDS im wondering what else 
out there might be better.


Regards,
David
___
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug


[melbourne-pug] PyCharm - Accidently enabled Unit Tests and cant turn off

2014-08-26 Thread David Crisp

Hello,

I know a few people here use PyCharm so I am hopeing sombody can answer my 
question:


Somehow a little while ago I accidently enabled Unit Testing on my code 
and now every time I go to run my code it runs a unit test instead of just 
the code.


I have no idea what button I pressed and I cant find where to enable or 
disable it.


Unit Tests are now enabled by default in a new project.

This is doing my head in... HOW DO I DISABLE UNIT TESTS as a default

Regards,
David
___
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug


Re: [melbourne-pug] PyCharm - Accidently enabled Unit Tests and cant turn off

2014-08-26 Thread David Crisp

AHhh.. dont mind me!..

I named a Class Test.   because I was trying to test a feature.

WHat does this do when you do it in pycharm!  thats right.  it kicks in 
the unit test feature..


I think.. when I renamed the class to a proper name the unit testing 
disapeared.


*waves fists at crazy design*


On Wed, 27 Aug 2014, David Crisp wrote:


Hello,

I know a few people here use PyCharm so I am hopeing sombody can answer my 
question:


Somehow a little while ago I accidently enabled Unit Testing on my code and 
now every time I go to run my code it runs a unit test instead of just the 
code.


I have no idea what button I pressed and I cant find where to enable or 
disable it.


Unit Tests are now enabled by default in a new project.

This is doing my head in... HOW DO I DISABLE UNIT TESTS as a default

Regards,
David


___
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug


[melbourne-pug] Variable Inheritence between modules. I have no idea!

2014-09-11 Thread David Crisp

Hello,

I've managed to muddle my way through python for the last while and have 
finally come up with something I dont know how to deal with.


(I have included a simplified code group below that represents what m 
trying to do and see)


I have a main module (test6.py)  which calls a configuration module 
(test8.py)  and then a number of other modules (test7 etc) which use the 
data from the configuration  module.  (ie:  configuration.output returns 
excel)


when I run the code I get the following error:
C:\Python33\python.exe  C:/Users/dcrisp/Documents/Python/gui/test6.py
sql
Traceback (most recent call last):
excel
  File C:/Users/dcrisp/Documents/Python/gui/test6.py, line 10, 
in module

mainWin = test7.MainWindow()
  File C:\Users\dcrisp\Documents\Python\gui\test7.py, line 5, 
in __init__

if configuration.input.upper() == EXCEL:
NameError: global name 'configuration' is not defined

Which is telling me that configuration isnt a global ...

Help?  please?  OKay,  an actual question.

How do I read the configuration opbject from within test7 when it is 
called from test6?I dont really want to call it from every module that 
needs it as there is meant to be some write back functionality happening 
to a configuration file and if I try and do that from more than one entry 
point I will end up writing a corrupted config back.  So A single entry 
point for configuration would be nice..


Or am I doing it wrong?

Whats the best way of doing what I want to do.

Again, if I havent asked the right questions, please guide and I will try 
and provide the information you need.


Regards,
David Crisp

Three simplified files provided below.

Module 1:
test6.py
import test8
import test7

if __name__ == '__main__':
configuration = test8.client_configuration()

print(configuration.output)
print(configuration.input)

mainWin = test7.MainWindow()
pass

Module 2:
test7.py
class MainWindow():
def __init__(self):
if configuration.input.upper() == EXCEL:
print(excel in)
elif configuration.input.upper() == SQL:
print(SQL in)
else:
print(Inappropriate Configuration Set)


if __name__ == '__main__':
import test8
configuration = test8.client_configuration()
mainWin = MainWindow()
pass

Module 3:
test8.py
class client_configuration():
def __init__(self):
self.input = excel
self.output = sql

if __name__ == '__main__':
configuration = client_configuration()

print(configuration.input)
print(configuration.output)
___
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug


[melbourne-pug] Python 3 and PySide shearing of properties from other classes

2017-05-07 Thread David Crisp
A problem in two parts with their own questions.   What is the terminology
for something, and then how would I do it.

My problem is that I don't know the correct Pythonic (or even general
programming terminology) term to use to search for what I am trying to do.
This makes it very difficult to go searching for the answer to my problem.

What is the correct terminology for the following:

I have a Main class that instantiates a Configuration class that handles
reading the settings file and then setting up properties.The same main
class then calls a mainWindow GUI  which has a configuration gui that I
want to be able to use and set the properties in the Configuration
class. I not sure what this terminology is.

For what its worth, I am using PySide, converting the .ui files to python
files and handling the gui content in python instead of the .ui file if
that helps.

In the following example each of the python files contain a single class.
(makes for a lot of files but it seems to work in my head)

Main -\
  | Configuration
  |- guiMainWindow -\
   |
   \--guiConfigWindow

Given that:
How do I set it up so that the properties set in the configuration class
can be accessed and set by the guiConfigWindow class?

Mind you,  if I know what the correct terminology is and can find some well
written examples I will have this problem solved before you can say "We
needed this code last Friday,  Today was meant to be release day"

I asked on StackOverflow a while ago but haven't had any responses.
David
___
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug


Re: [melbourne-pug] FroSolPy Fronius Inverter Data Collector / Code Feedback

2018-06-03 Thread David Crisp
Hi Dave,
Thank you for these ideas.Since I posted this the code has got longer
as I have dived in and added more comments and docstrings to all the
properties.   Once I have finished commenting and documenting the
functional code I will look at breaking it out in to separate files.   I
could probably do it BEFORE I finish the commenting but i'm on a bit of a
role and if I get distracted I will probably never get back to it.
Regards,
David

On 18 May 2018 at 14:41, David O'Keeffe  wrote:

> Hey David,
>
> I've been working on something similar for the Sungrow SH5K inverter
> talking through the Modbus protocol. From looking over your code briefly,
> it's an almost 2000 line script, I can't easily make sense of what your
> logic is.
>
> I'd take the long list of initializations out as a dictionary in another
> py file and write an abstract function for code blocks like this.
>
> @property
> def PowerApparent_S_Phase_1(self):
> if (self._checkdatacurrency(self.MeterRealTimeData.
> PowerApparent_S_Phase_1)):
> return self.MeterRealTimeData.PowerApparent_S_Phase_1.Value
> else:
> self._GetMeterRealtimeData()
> return self.MeterRealTimeData.PowerApparent_S_Phase_1.Value
> @property
> def PowerApparent_S_Phase_2(self):
> if (self._checkdatacurrency(self.MeterRealTimeData.
> PowerApparent_S_Phase_2)):
> return self.MeterRealTimeData.PowerApparent_S_Phase_2.Value
> else:
> self._GetMeterRealtimeData()
> return self.MeterRealTimeData.PowerApparent_S_Phase_2.Value
> Cheers,
> Dave
>
>
> On Fri, May 18, 2018 at 2:05 PM, William ML Leslie <
> william.leslie@gmail.com> wrote:
>
>> On 18 May 2018 at 13:40, paul sorenson  wrote:
>> > My inverter came with a CD-ROM which would push a cloud somewhere but I
>> > reckon it would be fun to crowd source really granular data.
>> >
>>
>> The ability to push clouds is a great feature for a solar inverter to
>> have.
>>
>> --
>> William Leslie
>>
>> Notice:
>> Likely much of this email is, by the nature of copyright, covered
>> under copyright law.  You absolutely MAY reproduce any part of it in
>> accordance with the copyright law of the nation you are reading this
>> in.  Any attempt to DENY YOU THOSE RIGHTS would be illegal without
>> prior contractual agreement.
>> ___
>> melbourne-pug mailing list
>> melbourne-pug@python.org
>> https://mail.python.org/mailman/listinfo/melbourne-pug
>>
>
>
> ___
> melbourne-pug mailing list
> melbourne-pug@python.org
> https://mail.python.org/mailman/listinfo/melbourne-pug
>
>
___
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug


Re: [melbourne-pug] FroSolPy Fronius Inverter Data Collector / Code Feedback

2018-06-03 Thread David Crisp
Hello Alaa,

First off I must apologise for not responding earlier,   gmail insists on
filing all my melbourne-pug emails way over there hidden away from my
normal inbox!

Thank you for looking at the code and providing feedback! This is the sort
of useful information I was hoping to get!   Once I have had a chance to
process the information I will comment on why i did things originally.

Regards,
David

On 18 May 2018 at 23:33, Alaa Salman  wrote:

> Hi David,
>
> I am not sure what kind of code review you're after but I had a quick look
> at the code and though I can't comment on the functionality, there are a
> few things that stand out.
>
> 1- That's a lot of code to sit in a single file, you might want to
> consider splitting it up over multiple files or modules
>
> 2- The code pattern where you check for key existence before you fetch its
> value can be replaced with the get() dict function which would cut down on
> a lot of the code. Some lines in there can also be replaced with a default
> dict.
>
> 3- You'll find that most python code follows the directions in pep8 for
> style. There's no right or wrong for this one just convention/consistency
> and tradition.
>
> 4- I am not sure why you're doing __new__.__defaults__ = (None,) * len(
> self.CommonInverterValues.IAC._fields). There are more expressive ways to
> do this.
>
> 5- Something like "url={protocol}://{host}" can be extracted to a
> common location since usually this wouldn't change for a single invocation.
>
> 6- Using named tuples inside of classes might make your code a bit more
> difficult to follow. Maybe consider encapsulating the different objects in
> different classes and populate those.
>
> 7- You mentioned there are no tests. I don't see any logic in there that
> could use testing. However, you can write tests to make sure that your code
> handles unexpected values as a start.
>
>
> I hope this helps. Very nice work on commenting your code and keeping it
> tidy. Please feel free to ask any questions you might have to the list and
> I'm sure we're all happy to help.
>
>
>
> On 18/05/18 14:05, melbourne-pug-requ...@python.org wrote:
>
> --
>
> Message: 1
> Date: Fri, 18 May 2018 09:35:16 +1000
> From: David Crisp  
> To: Melbourne Python Users Group  
> 
> Subject: [melbourne-pug] FroSolPy Fronius Inverter Data Collector /
>   Code Feedback
> Message-ID:
>
> 
> Content-Type: text/plain; charset="utf-8"
>
> Gday,
>
> I'm not sure if this is appropriate to ask for or not but I was wondering
> if there was anybody who would be happy to do a quick code review / code
> feedback on my Fronius Solar module I have written  and give me some
> feedback on it.
>
> I have been working on this module for a while and I think I'm beginning to
> not be able to see the trees for the forest.   It is NOT finished yet but
> it does what I need it to do for the moment.
>
> There's no unit tests though.  I haven't worked out how to do these for
> dynamic data collected from APIs etc which could return anything.
>
> Currently being unemployed and not having access to a development team I
> don't get a chance to drop code in front of more experienced people and get
> ideas from them.
>
> The module should be able to be found at the following 
> location.https://github.com/dcrispgit/FroSolPy
>
> Bonus Points if you have your own Fronius solar inverter and you can
> actually run this code and retrieve data from it.
>
> If it's not appropriate to ask that then feel free to ignore or point me in
> the direction of somewhere that can help.
>
> Regards,
> David
> -- next part --
> An HTML attachment was scrubbed...
> URL: 
> <http://mail.python.org/pipermail/melbourne-pug/attachments/20180518/8219323b/attachment-0001.html>
>  
> <http://mail.python.org/pipermail/melbourne-pug/attachments/20180518/8219323b/attachment-0001.html>
>
> --
>
>
>
> ___
> melbourne-pug mailing list
> melbourne-pug@python.org
> https://mail.python.org/mailman/listinfo/melbourne-pug
>
>
___
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug


[melbourne-pug] Fronius API and Python - queries about a third party module.

2018-04-19 Thread David Crisp
A couple of questions to the more experienced Python developers here.

I have been working with my Fronius Symo solar inverter to extract data
from the onboard API.   It's actually a reasonably simple process of making
a web request and then processing the resulting JSON.

There is one third party module, pyfronius, that has been written already
that sort of performs these requests, but when I look inside the code I
find myself asking lots of whys.There are a couple of things that the
author has done that don't seem Pythonic  and I was wondering if somebody
could help clear up my thoughts.

The two things I have noticed that I want to query

1)  Everything in the __init__.py
2)  Using Asynchronous web calls to the API

Everything in the __init__.py file:
The functional part of the module consists of a single __init__.py file.
All the code is in this file.  My understanding of the usage of this file
is to provide a layout of the actual code files and perform global imports
etc.  The __init__.py references online never talk about putting actual
code in there.   Putting code in the file doesn't seem to be the right
thing to do.  I have seen this a couple of times with more obscure
modules and my uninformed gut instinct is to say that the developer didnt
quite know what they were doing.

Using Asynchronous web calls to the API:
The developer has used the asyncio module to perform the web queries and
has used a lot of @asyncio.coroutine functions throughout the code.
This doesn't seem... right for a module that simply goes to the web server
and says "gime what you got... hmm.. yup.. thanks"
This one is a little more along the lines of "developer choice"  I think
the method chosen overly complicates the design of the module.
It seems something like requests could have been a better choice of module
to use.

Now,  I'm not trying to point fingers at the original developer.  There may
be perfectly logical and sensible and Pythonic reasons for doing what they
have done.I'm hoping a more experienced developer can hypothesis.

I am writing my own module to talk to the inverter.  Originally it was
based on pyfronius but I have found myself completely reworking the methods
to try and add exception handling and layout the code in a slightly better
layout.

I would be interested to know other peoples comments about the style..
David
___
melbourne-pug mailing list
melbourne-pug@python.org
https://mail.python.org/mailman/listinfo/melbourne-pug