Getting "LazyImporter' object is not callable" error when trying to send email using python smtplib

2018-03-26 Thread Sum
Hi,

Getting "LazyImporter' object is not callable" error.
I have enabled allow less secure app setting in sender gmail.

Code :

import smtplib
from email import MIMEBase
from email import MIMEText
from email.mime.multipart import MIMEMultipart
from email import Encoders
import os

def send_email(to, subject, text, filenames):
try:
gmail_user = 'x...@gmail.com'
gmail_pwd = ''

msg = MIMEMultipart()
msg['From'] = gmail_user
msg['To'] = ", ".join(to)
msg['Subject'] = subject
msg.attach(MIMEText(text))

for file in filenames:
part = MIMEBase('application', 'octet-stream')
part.set_payload(open(file, 'rb').read())
Encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment;
filename="%s"'% os.path.basename(file))
msg.attach(part)

mailServer = smtplib.SMTP("smtp.gmail.com:465")
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
mailServer.login(gmail_user, gmail_pwd)
mailServer.sendmail(gmail_user, to, msg.as_string())
mailServer.close()
print('successfully sent the mail')

except smtplib.SMTPException,error::
print str(error)

if __name__ == '__main__':
attachment_file = ['t1.txt','t2.csv']
to = "xxx...@gmail.com"
TEXT = "Hello everyone"
SUBJECT = "Testing sending using gmail"

send_email(to, SUBJECT, TEXT, attachment_file)


Getting below error :
File "test_mail.py", line 64, in send_email(to, SUBJECT, TEXT,
attachment_file) File "test_mail.py", line 24, in send_email
msg.attach(MIMEText(text)) TypeError: 'LazyImporter' object is not callable
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting "LazyImporter' object is not callable" error when trying to send email using python smtplib

2018-03-26 Thread Sum
Thanks Steve for your inputs.
Now I am able to run the code successfully.

# Made changes to import statements as below:
from email.mime.base import MIMEBase
from email.mime.text import MIMEText


Apologies for the typo and indentation error in above mail.

Regards,
Sumit


On Mon, Mar 26, 2018 at 6:04 PM, Steven D'Aprano <
steve+comp.lang.pyt...@pearwood.info> wrote:

> On Mon, 26 Mar 2018 16:47:26 +0530, Sum wrote:
>
> > Hi,
> >
> > Getting "LazyImporter' object is not callable" error. I have enabled
> > allow less secure app setting in sender gmail.
> >
> > Code :
>
> The code you show is not the same as the code you are actually running.
> The error message you give says:
>
> File "test_mail.py", line 64, in
>   send_email(to, SUBJECT, TEXT, attachment_file)
> File "test_mail.py", line 24, in send_email
>   msg.attach(MIMEText(text))
> TypeError: 'LazyImporter' object is not callable
>
>
> Notice the quoted line 24. Here it is again:
>
> msg.attach(MIMEText(text))
>
> But line 24 in the code you give us is:
>
> msg.attach(part)
>
>
> which is different. Also, you have a line of code:
>
> except smtplib.SMTPException,error::
>
> Notice the two colons at the end of the line? That's a syntax error. So
> the code you have shown us cannot possibly be the same as the code you
> are running.
>
> Please review your code, copy and paste the complete traceback, starting
> with the line "Traceback", and make sure that you have run the code you
> show us.
>
> It might help to read this page:
>
> http://sscce.org/
>
> It's written for Java programmers, but the ideas apply equally to Python.
>
>
> Thank you,
>
>
>
> --
> Steve
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


How to add values from test steps in pytest excel report

2018-04-27 Thread Sum
Hi,

I am using python 2.7 and pytest version 3.2.1
I am using pytest excel plugin to run the pytest and generate test report
in excel format.

Step to install pytest excel : pip install pytest-excel

I am running my pytest test using below :

py.test --excelreport=report.xls e_test.py

Output Test report excel format :

SUITE NAME  TEST NAME   DESCRIPTION RESULT  DURATIONMESSAGE FILE
NAME   MARKERSTestSumFlow test_step1  PASSED  15.24737811
e_test.py

My query is that I want to display the values from my corresponding test
steps in pytest.
e.g. if my test step is following, then how do I display the output of
test_step1 "newNum" in the excel report.

def test_step1(fNum, sNum):
newNum = fNum - sNum
print newNum


Regards,
Sumit
-- 
https://mail.python.org/mailman/listinfo/python-list


How to set/update value in a xml file using requests in python

2018-02-06 Thread Sum J
My xml file is located in local network : 
http://192.168.43.109/DevMgmt/NetAppsDyn.xml

Below is a part content of above xml I want to update :




off


I want to set value for 'ResourceUI' and 'Port' field in above xml.
I have used below code :

 data = {
  'ResourceURI':'web-proxy.xxx.yy.com',
  'Port':8080
}

URL = 'http://192.168.75.165/DevMgmt/NetAppsDyn.xml'

# content type
head = {'Content-type': 'text/xml'}
# sending get request
gr= requests.get(url=URL)
print gr

# sending put request
r = requests.put(url=URL, data=data,headers=head)
print r.status_code
# extracting response text
output_xml = r.text
print("The op xml is:%s" % output_xml)

Issue : The fields are not getting updated in xml using put request. I am able 
to see the response for get (request) , but for put request it is throwing 
errror code : 301 , resource has been moved permanently.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] How to set/update value in a xml file using requests in python

2018-02-12 Thread Sum J
Thanks Dan for your response.


I have updated the data to be sent in xml format and now I am able to
update the required fields using put request.

data= '''

  
   web-proxy.xx.com
   8080
   
   on
  
'''


On Thu, Feb 8, 2018 at 10:15 PM, Dan Stromberg  wrote:

> This is more relevant to python-list than python-dev. I've added
> python-list to the To header.
>
> Gmail doesn't appear to allow setting a reply-to for a single message,
> so I've not set that; please, when replying, drop python-dev from the
> to: header.
>
> You'll likely want to set up some kind of REST endpoint to allow
> updating your xml file.  Imagine if anyone could change anyone else's
> xml files - it'd be pretty chaotic.
>
> Perhaps flask would be appropriate?
> http://flask.pocoo.org/docs/0.12/quickstart/
>
> You likely will want a PUT or a POST HTTP verb:
> https://stackoverflow.com/questions/107390/whats-the-
> difference-between-a-post-and-a-put-http-request
>
> HTH.
>
> On Thu, Feb 8, 2018 at 12:38 AM, Sum J  wrote:
> > My xml file is located in local network:
> >
> > http://192.168.43.109/DevMgmt/NetAppsDyn.xml
> >
> > Below is a part content of above xml I want to update :
> >
> > 
> >
> > 
> > 
> > 
> > off
> > 
> >
> > 
> >
> > I want to set the value for 'ResourceUI' and 'Port' field in above xml.
> >
> > I have used below code :
> >
> >  import requests
> >  data = {
> >   'ResourceURI':'web-proxy.xxx.yy.com',
> >   'Port':8080
> > }
> >
> > URL = 'http://192.168.75.165/DevMgmt/NetAppsDyn.xml'
> >
> > # content type
> > head = {'Content-type': 'text/xml'}
> > # sending get request
> > gr= requests.get(url=URL)
> > print gr
> >
> > # sending put request
> > r = requests.put(url=URL, data=data,headers=head)
> > print r.status_code
> > # extracting response text
> > output_xml = r.text
> > print("The op xml is:%s" % output_xml)
> >
> > Issue : The fields are not getting updated in xml using put request. I am
> > able to see the response for get (request) , but for put request it is
> > throwing errror code : 301 , resource has been moved permanently.
> >
> >
> >
> > ___
> > Python-Dev mailing list
> > python-...@python.org
> > https://mail.python.org/mailman/listinfo/python-dev
> > Unsubscribe:
> > https://mail.python.org/mailman/options/python-dev/drsalists%40gmail.com
> >
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Getting "ValueError: need more than 1 value to unpack" while trying to read a value from dictionary in python

2018-02-15 Thread Sum J
Below is my code. Here I want to read the "ip address" from s


 s= '''
Power On Enabled = On
State: connected
Radio Module: Unknown
noise: -097
signalStrength: -046
ip address: 192.168.75.147
subnet mask: 255.255.255.0
IPv4 address configured by DHCP
Mac Addr: ac:e2:d3:32:00:5a
Mode: infrastrastructure
ssid: Cloudlab
Channel: 1
Regulatory: World Safe
Authencation: WPA2/PSK
Encryption:  AES or TKIP
'''

   s = s.replace("=",":")
   # s = s.strip()
   print s

  d = {}
  for i in s:
 key, val = i.split(":")
 d[key] = val.strip()

  print d
  print d["ip address"]


Getting below error :
 key, val = i.split(":")
ValueError: need more than 1 value to unpack
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting "ValueError: need more than 1 value to unpack" while trying to read a value from dictionary in python

2018-02-15 Thread Sum J
Thanks Chris :)

Its working now.

Regards,
Sumit

On Thu, Feb 15, 2018 at 4:55 PM, Chris Warrick  wrote:

> On 15 February 2018 at 12:07, Sum J  wrote:
> > Below is my code. Here I want to read the "ip address" from s
> >
> >
> >  s= '''
> > Power On Enabled = On
> > State: connected
> > Radio Module: Unknown
> > noise: -097
> > signalStrength: -046
> > ip address: 192.168.75.147
> > subnet mask: 255.255.255.0
> > IPv4 address configured by DHCP
> > Mac Addr: ac:e2:d3:32:00:5a
> > Mode: infrastrastructure
> > ssid: Cloudlab
> > Channel: 1
> > Regulatory: World Safe
> > Authencation: WPA2/PSK
> > Encryption:  AES or TKIP
> > '''
> >
> >s = s.replace("=",":")
> ># s = s.strip()
> >print s
> >
> >   d = {}
> >   for i in s:
> >  key, val = i.split(":")
> >  d[key] = val.strip()
> >
> >   print d
> >   print d["ip address"]
> >
> >
> > Getting below error :
> >  key, val = i.split(":")
> > ValueError: need more than 1 value to unpack
> > --
> > https://mail.python.org/mailman/listinfo/python-list
>
> If you iterate over a string, you are iterating over individual
> characters. Instead, you need to split it into lines, first stripping
> whitespace (starts and ends with an empty line).
>
> s = s.strip().replace("=",":")
> print s
>
> d = {}
> for i in s.split('\n'):
> try:
> key, val = i.split(":")
> d[key.strip()] = val.strip()
> except ValueError:
> print "no key:value pair found in", i
>
>
> (PS. please switch to Python 3)
>
> --
> Chris Warrick <https://chriswarrick.com/>
> PGP: 5EAAEA16
>
-- 
https://mail.python.org/mailman/listinfo/python-list


How to reset system proxy using pyhton code

2018-02-19 Thread Sum J
Hi,

I am using below python code (Python 2.7) to reset the proxy of my Ubuntu
(Cent OS 6) system, but I am unable to reset the proxy:

Code :
import os
 print "Unsetting http..."
 os.system("unset http_proxy")
 os.system("echo $http_proxy")
 print "http is reset"

Output :
Unsetting http...
http://web-proxy..xxx.net:8080
http is reset
Process finished with exit code 0

It should not return ' http://web-proxy..xxx.net:8080 ' in output.

I run the same unset command  from terminal , then I see that proxy is
reset:

[trex@sumlnxvm ~]$ unset $HTTP_PROXY
[trex@sumlnxvm ~]$ echo $HTTP_PROXY

[trex@sumlnxvm ~]$


Please suggest how to reset system proxy using Python Code

Regards,
Sumit
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bitstream -- Binary Data for Humans

2018-03-05 Thread sum abiut
Thanks

On 6/03/2018 7:13 AM, "Sébastien Boisgérault" <
sebastien.boisgera...@gmail.com> wrote:

Hi everyone,

I have released bitstream, a Python library to manage binary data (at the
byte or bit level), hopefully without the pain that this kind of thing
usually entails :)

If you have struggled with this topic in the past, please take a look at
the documentation (http://boisgera.github.io/bitstream/) and tell me what
you think.

Cheers,

Sébastien
--
https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


pymssql

2016-09-08 Thread sum abiut
Hi,
i have used pymssql to connet to windows database but i want to be able
iterate and  only print out some specific fields.

here is what i did

conn=pymssql.connect(server,username,password,database)
cus=conn.cursor()
cus.execute("SELECT * FROM glbud ")

for row in cus:
   print(row)
this works perfect, but when i try to iterate through and only print out
specific fields i got the error NameError: name 'budget_code' is not defined


for row in cus:
   print(row.budget_code)


NameError: name 'budget_code' is not defined

the column name is budget_code, in mssql server 2008


any idea what i am doing wrong? please advise
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pymssql

2016-09-08 Thread sum abiut
ok did some changes:

conn=pymssql.connect(server,username,password,database)
 cus=conn.cursor(
cus.execute("SELECT budget_code,budget_description,rate_type FROM glbud")
for row in cus:
print(row)


the above code display the selected column


but when i iterate and try to print the fields, its not displaying anything
and its not giving any error.

conn=pymssql.connect(server,username,password,database)
 cus=conn.cursor(
cus.execute("SELECT budget_code,budget_description,rate_type FROM glbud")
for row in cus:
print(row.budget_code,row.budget_description,row.rate_type)


the above code it doesn't print out anything and it doesn't give me any
error.

any assistance will be very much appreciated.




On Fri, Sep 9, 2016 at 1:38 PM, Lawrence D’Oliveiro 
wrote:

> On Friday, September 9, 2016 at 12:48:50 PM UTC+12, sum abiut wrote:
> > cus.execute("SELECT * FROM glbud ")
>
> Never use “select *”, except for testing.
>
> > for row in cus:
> >print(row)
> > this works perfect, but when i try to iterate through and only print out
> > specific fields i got the error NameError: name 'budget_code' is not
> defined
>
> Possibly because you are getting back a tuple? Are you expecting some
> other object type?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pymssql

2016-09-11 Thread sum abiut
Thanks heaps for your comments, manage to get it work using the as_dict`
parameter of the `cursor` object,

cus=conn.cursor(as_dict=True)
cus.execute("SELECT budget_code,budget_description,rate_type FROM glbud")
for row in cus:
print(row['budget_code'],row['budget_description'],row['rate_type'])


cheers,


On Sat, Sep 10, 2016 at 3:22 PM, Miki Tebeka  wrote:

> > for row in cus:
> >print(row.budget_code)
> >
> >
> > NameError: name 'budget_code' is not defined
> You'll need to use a DictCursor to be able to access rows by name and not
> position (which IMO is the preferred way).
>
> cus = conn.cursor(pymysql.cursors.DictCursor)
> cus.execute("SELECT * FROM glbud ")
> for row in cus:
> print(row['budget_code'])
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


mssql date format

2016-09-11 Thread sum abiut
Hi,
I am pulling data from an mssql server database and got a date in this
format: 733010
please advise what of date is this and how to i convert it to a readable
date?

i use pyssql to connect to the database and pull data fro the database.

thanks in advance,

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


Re: mssql date format

2016-09-12 Thread sum abiut
Thanks for the response,
i pulling data from an mssql database and i need to convert the date
column. how to i covert and pass it to my template. i am using Django

this is what i did

conn=pymssql.connect(server,username,password,database)
#cus=conn.cursor()
cus=conn.cursor(as_dict=True)
cus.execute("SELECT
account_code,currency_code,balance_date,debit,credit,net_change,home_net_change
FROM glbal where account_code= '50101001CORP'")

return render_to_response('revenue_budget.html',locals())


how to i  convert the balance_date with the code below:



import datetime
>>> datetime.datetime.fromordinal(733010)
>>>
>> datetime.datetime(2007, 11, 30, 0, 0)



On Mon, Sep 12, 2016 at 12:15 PM, MRAB  wrote:

> On 2016-09-12 01:37, sum abiut wrote:
>
>> Hi,
>> I am pulling data from an mssql server database and got a date in this
>> format: 733010
>> please advise what of date is this and how to i convert it to a readable
>> date?
>>
>> i use pyssql to connect to the database and pull data fro the database.
>>
>> Does the date "30 November 2007" look reasonable for that data?
>
> If it does, it's a """proleptic Gregorian ordinal, where January 1 of year
> 1 has ordinal 1""" (from the docs):
>
> import datetime
>>>> datetime.datetime.fromordinal(733010)
>>>>
>>> datetime.datetime(2007, 11, 30, 0, 0)
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Julian date to calendar date conversion

2016-09-12 Thread sum abiut
Hi,
how to convert julian date to a calander date

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


Re: Julian date to calendar date conversion

2016-09-12 Thread sum abiut
Thanks

On Tue, Sep 13, 2016 at 12:37 PM, MRAB  wrote:

> On 2016-09-13 02:12, sum abiut wrote:
>
>> Hi,
>> how to convert julian date to a calander date
>>
>> Have a look at the jdcal module on PyPI:
>
> https://pypi.python.org/pypi/jdcal
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


julian 0.14 library

2018-04-03 Thread sum abiut
Hi,
Has anyone try this https://pypi.python.org/pypi/julian/0.14

i got this error trying to import julian

>>> import julian
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python2.7/dist-packages/julian/__init__.py", line 1,
in 
from julian.julian import to_jd, from_jd
  File "/usr/local/lib/python2.7/dist-packages/julian/julian.py", line 5
def __to_format(jd: float, fmt: str) -> float:
  ^
SyntaxError: invalid syntax



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


Re: julian 0.14 library

2018-04-04 Thread sum abiut
I got the error  below, tryinig in on python 3.2.

import julian
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named julian


On Thu, Apr 5, 2018 at 3:21 AM, Thomas Jollans  wrote:

> On 2018-04-04 05:44, Chris Angelico wrote:
> > On Wed, Apr 4, 2018 at 12:24 PM, sum abiut  wrote:
> >> Hi,
> >> Has anyone try this https://pypi.python.org/pypi/julian/0.14
> >>
> >> i got this error trying to import julian
> >>
> >>>>> import julian
> >> Traceback (most recent call last):
> >>   File "", line 1, in 
> >>   File "/usr/local/lib/python2.7/dist-packages/julian/__init__.py",
> line 1,
> >> in 
> >> from julian.julian import to_jd, from_jd
> >>   File "/usr/local/lib/python2.7/dist-packages/julian/julian.py", line
> 5
> >> def __to_format(jd: float, fmt: str) -> float:
> >>   ^
> >> SyntaxError: invalid syntax
> >>
> >
> > Looks like that package requires Python 3, but was uploaded to PyPI
> > without any version tags. You could try running it in Python 3.x, but
> > there's no way to know which ".x" versions are going to work.
>
> the cheeseshop description says 3.2+
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


jilian to Gregorian date conversion error

2018-04-24 Thread sum abiut
Hi,

i get the error message:

an integer is required

when i am try to convert from julian date to  Gregorian date

in my view.py, after i have query the db i want to convert the applied date
from julian date to Gregorian date but i got the above error,

convert_date=(datetime.date.fromordinal(rate.columns.date_applied))


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


Re: jilian to Gregorian date conversion error

2018-04-24 Thread sum abiut
Thanks date example is 736788 in julian





On Wed, Apr 25, 2018 at 12:34 PM, Dennis Lee Bieber 
wrote:

> On Wed, 25 Apr 2018 00:55:39 +0100, MRAB 
> declaimed the following:
>
>
> >Also, the integer is interpreted as a "proleptic Gregorian ordinal", not
> >a Julian date.
>
> You didn't provide examples of the dates in question.
>
> https://en.wikipedia.org/wiki/Conversion_between_Julian_and_
> Gregorian_calendars
>
> Any date before 1582-10-15 is a "proleptic", since the Gregorian
> calendar did not exist in those years.
>
> https://planetcalc.com/505/
>
> https://www.amazon.com/Practical-Astronomy-Calculator-Peter-Duffett-
> Smith/dp/0521356997/ref=sr_1_4?ie=UTF8&qid=1524619974&sr=8-
> 4&keywords=astronomy+calculator
> Has programs for converting between Julian and Gregorian (astronomical
> definitions).
>
>
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: jilian to Gregorian date conversion error

2018-04-25 Thread sum abiut
ok so i have fixed that using the for loop

result_proxy=connection.execute(stmt).fetchall()
for a in result_proxy:
test=datetime.date.fromordinal(int(a.date_applied))


Now if i want to pass a range of date to date_applied above. How to i do that?

I know in sql i did did it like this
rate.columns.date_applied.between(covert,convert1)

where convert and convert1 are the range of date


cheers,



On Thu, Apr 26, 2018 at 4:47 AM, Dennis Lee Bieber 
wrote:

> On Wed, 25 Apr 2018 13:43:15 +1100, sum abiut 
> declaimed
> the following:
>
> >Thanks date example is 736788 in julian
> >
>
> Okay...
> https://en.wikipedia.org/wiki/Julian_day#Julian_or_
> Gregorian_calendar_from_Julian_day_number
>
> Using a calculator program based upon Duffett that converts to
>
> -2695.03205
>
> or
> midnight, Mar 20, 2696BC
> (there is no year 0, so BC dates convert with a 1 year delta... 1BC is
> 0.xxx)
>
> Note that   datetime.date.fromordinal() is counting from
> Jan 1, 1AD; it
> is NOT Julian Day which counts from noon Jan 1, 4713BC
>
> Treating your number as an ordinal gives
>
> >>> import datetime
> >>> datetime.date.fromordinal(736788)
> datetime.date(2018, 4, 4)
> >>>
>
> ... So your original problem is not with the number, per se, but perhaps in
> the format it has in
>
> rate.columns.date_applied
>
> is there a possibility that is a string field and not numeric?
>
> >>> st = "736788"
> >>> datetime.date.fromordinal(st)
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: an integer is required
> >>> datetime.date.fromordinal(736788.0)
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: integer argument expected, got float
> >>> import decimal
> >>> dc = decimal.Decimal(st)
> >>> dc
> Decimal('736788')
> >>> datetime.date.fromordinal(dc)
> datetime.date(2018, 4, 4)
> >>>
>
>
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: jilian to Gregorian date conversion error

2018-04-29 Thread sum abiut
Hi Dennnis,
Thank you for your email. My issue is i what to be able to display the rage
of date base on the start and end date that was selected but i don't know
how to do that.
when i did a for look from my template for example.

{%for a in result_proxy%}
  {{a.date_applied}}

{%endfor%}

i was able to display the range of dates but its is julian date but i don't
want the dates to be in julian dates. I want the dates to be in a gregorian
date where by the end users can understand it. Which is why i was trying to
convert that from my view.py before passing the the parameter to the
template.

appreciate any assistances.

cheers,

On Sun, Apr 29, 2018 at 2:39 AM, Dennis Lee Bieber 
wrote:

> On Thu, 26 Apr 2018 15:43:43 +1100, sum abiut 
> declaimed
> the following:
>
> >ok so i have fixed that using the for loop
> >
> >result_proxy=connection.execute(stmt).fetchall()
> >for a in result_proxy:
> >test=datetime.date.fromordinal(int(a.date_applied))
> >
> >
> >Now if i want to pass a range of date to date_applied above. How to i do
> that?
> >
> >I know in sql i did did it like this
> >rate.columns.date_applied.between(covert,convert1)
> >
> >where convert and convert1 are the range of date
>
> You are now getting into basic logic and algorithm design -- which
> is
> not something specific to Python.
>
> Since I don't have access to the database schema, nor most of the
> surrounding code, I can only brute force a solution... It would probably be
> better to modify the SQL "stmt" to only return the desired entries but...
>
>
> ...
> for a in r_p:
> ada = int(a.date_applied)
> if convert <= ada <= convert1:
> ...
>
>
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: web facing static text db

2016-05-01 Thread sum abiut
Django is an excellent framework. you can use it with sqlite.

cheers

On Sat, Apr 30, 2016 at 7:17 PM, Gordon Levi  wrote:

> "Fetchinson ."  wrote:
>
> >Hi folks,go >
> >I have a vo ery specific set of requirements for a task and was
> >wondering if anyone had good suggestions for the best set of tools:
> >
> >* store text documents (about 10 pages)
> >* the data set is static (i.e. only lookups are performed, no delete,
> >no edit, no addition)
> >* only one operation required: lookup of pages by matching words in them
> >* very simple web frontend for querying the words to be matched
> >* no authentication or authorization, frontend completely public
> >* deployment at webfaction
> >* deadline: yesterday :)
> >
> >Which web framework and db engine would you recommend?
> >
> >So far I'm familiar with turbogears but would be willing to learn
> >anything if sufficiently basic since my needs are pretty basic (I
> >think).
> >
>
> What do need that storing the documents in HTML format and Google
> Custom Search does not provide
> ?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


How to print out html tags excluding the attributes

2019-07-20 Thread sum abiut
I want to use regular expression to print out the HTML tags excluding the
attributes.

for example:

import re
html = 'Hitest test'
tags = re.findall(r'<[^>]+>', html)
for a in tags:
print(a)


the output is :








But I just want the tag, not the attributes







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


Re: SQLObject 3.3.0

2017-05-07 Thread sum abiut
Thanks for the info

On Mon, May 8, 2017 at 1:25 AM, Oleg Broytman  wrote:

> Hello!
>
> I'm pleased to announce version 3.3.0, the first stable release of branch
> 3.3 of SQLObject.
>
>
> What's new in SQLObject
> ===
>
> Features
> 
>
> * Support for Python 2.6 is declared obsolete and will be removed
>   in the next release.
>
> Minor features
> --
>
> * Convert scripts repository to devscripts subdirectory.
>   Some of thses scripts are version-dependent so it's better to have them
>   in the main repo.
>
> * Test for __nonzero__ under Python 2, __bool__ under Python 3 in BoolCol.
>
> Drivers (work in progress)
> --
>
> * Add support for PyODBC and PyPyODBC (pure-python ODBC DB API driver) for
>   MySQL, PostgreSQL and MS SQL. Driver names are ``pyodbc``, ``pypyodbc``
>   or ``odbc`` (try ``pyodbc`` and ``pypyodbc``). There are some problems
>   with pyodbc and many problems with pypyodbc.
>
> Documentation
> -
>
> * Stop updating http://sqlobject.readthedocs.org/ - it's enough to have
>   http://sqlobject.org/
>
> Tests
> -
>
> * Run tests at Travis CI and AppVeyor with Python 3.6, x86 and x64.
>
> * Stop running tests at Travis with Python 2.6.
>
> * Stop running tests at AppVeyor with pymssql - too many timeouts and
>   problems.
>
> For a more complete list, please see the news:
> http://sqlobject.org/News.html
>
>
> What is SQLObject
> =
>
> SQLObject is an object-relational mapper.  Your database tables are
> described
> as classes, and rows are instances of those classes.  SQLObject is meant
> to be
> easy to use and quick to get started with.
>
> SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
> Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).
>
> Python 2.6, 2.7 or 3.4+ is required.
>
>
> Where is SQLObject
> ==
>
> Site:
> http://sqlobject.org
>
> Development:
> http://sqlobject.org/devel/
>
> Mailing list:
> https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss
>
> Download:
> https://pypi.python.org/pypi/SQLObject/3.3.0
>
> News and changes:
> http://sqlobject.org/News.html
>
> Oleg.
> --
>  Oleg Broytmanhttp://phdru.name/p...@phdru.name
>Programmers don't die, they just GOSUB without RETURN.
> --
> https://mail.python.org/mailman/listinfo/python-list
>



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


converting Julian date to normal date

2017-06-05 Thread sum abiut
i am using python,and django as my web framework. I use  sqlalchemy to
connect to  MSSQL data that is running Epicor database. Epicor is using
julian

* date. How to you convert julian date to normal date*

*cheers,*
-- 
https://mail.python.org/mailman/listinfo/python-list