public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: [ANNOUNCEMENT] Updated: units 2.14-1
       [not found] <auto-000002683205@fwd1.webnames.ca>
@ 2017-05-22 10:50 ` Brian Inglis
  2017-05-22 18:09   ` Achim Gratz
  2017-05-22 18:38   ` Brian Inglis
  0 siblings, 2 replies; 7+ messages in thread
From: Brian Inglis @ 2017-05-22 10:50 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 2004 bytes --]

On 2017-04-27 13:20, Brian Inglis wrote:
> * units-2.14-1
> 
> The Units program converts quantities expressed in various scales to
> their equivalents in other scales. The units program can handle
> multiplicative scale changes as well as nonlinear conversions such as
> Fahrenheit to Celsius or wire gauge. Units comes with an annotated,
> extendable database defining over two thousand units.
> 
> This is an update to the latest upstream release, which now supports
> longer input expressions (e.g. a sum of more than 100 units), control
> characters treated as white space to avoid producing errors about
> invalid UTF-8, and includes 2980 units, 109 prefixes, and 96 nonlinear
> units.

Currency exchange rates are updated on every run of setup by a permanent
postinstall script
	/etc/postinstall/zp_units_cur.sh
running
	/usr/bin/units_cur
to access
	https://rss.timegenie.com
which uses HSTS to enforce https access, and whose security certificate
has expired, so runs will fail with message:
Error connecting to currency server. <urlopen error [SSL:
CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)>

If this causes you problems, please temporarily rename the current
update script /usr/bin/units_cur and replace by the attached, or replace
the line between the first try: and except ...: by the following lines:
[the first line is a comment, the remainder are indented two spaces]

#
http://stackoverflow.com/questions/36600583/python-3-urllib-ignore-ssl-certificate-verification
  import ssl
  ctx = ssl.create_default_context()
  ctx.check_hostname = False
  ctx.verify_mode = ssl.CERT_NONE
  currencies =
ET.parse(urllib.request.urlopen('https://rss.timegenie.com/forex.xml',context=ctx)).findall('data')

to ignore the security certificate expiry until it is renewed (hopefully
by sometime Tuesday after the holiday): when the security certificate
has been renewed, I will follow up here to let everyone know.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

[-- Attachment #2: units_cur --]
[-- Type: text/plain, Size: 4337 bytes --]

#!/usr/bin/python3
#
# Version 2  
# 9 July 2013
#
# Modified to use xml format output from timegenie instead of text file
#
# Version 3
# 7 March 2014
#
# Added checks for unicode currency names
#
# Version 3.1
# 23 June 2014
#
# Added test for non-unicode strings to prevent a runtime warning
#

import sys
import urllib.request, urllib.parse, urllib.error
import os
import xml.etree.ElementTree as ET
import codecs
from datetime import datetime
from unidecode import unidecode

outstr = ''

outfile='/usr/share/units/currency.units'  

if len(sys.argv)==2 and sys.argv[1] != '--help' and sys.argv[1] != '-h':
  outfile = sys.argv[1]
elif len(sys.argv) != 1:
  sys.stderr.write('\nUsage: {0} [filename]\n\n'.format(sys.argv[0]))
  sys.stderr.write('Update currency information for \'units\' into the specified filename or if no\n')
  sys.stderr.write('filename is given, the default: \'{0}\'.\n'.format(outfile))
  sys.exit(1)

try:
# http://stackoverflow.com/questions/36600583/python-3-urllib-ignore-ssl-certificate-verification
  import ssl
  ctx = ssl.create_default_context()
  ctx.check_hostname = False
  ctx.verify_mode = ssl.CERT_NONE
  currencies = ET.parse(urllib.request.urlopen('https://rss.timegenie.com/forex.xml',context=ctx)).findall('data')
except IOError as exc:
  sys.stderr.write('Error connecting to currency server. {0}\n'.format(exc))
  sys.exit(1)

# print codes here

codes = [x.find('code').text for x in currencies]
names = [x.find('description').text for x in currencies]
values = [x.find('rate').text for x in currencies]

# Sometimes currency rates are missing from the xml file
# Delete such currencies

while True:
  try:
    none = values.index(None)
    sys.stderr.write('no rate for "%s" (%s)\n' % (names[none], codes[none]))
    del codes[none]
    del names[none]
    del values[none]
  except ValueError:
    break

# Precious metals are showing up with weird prices (per gram?)
# Delete them

metalcodes = ['XAG','XAU','XPD','XPT']
for i in range(len(metalcodes)):
  try:
    badind = codes.index(metalcodes[i])
    del codes[badind]
    del names[badind]
    del values[badind]
  except ValueError:
    break

names = [x.lower().replace(' ','') for x in names]

foundunicode=False
for i in range(len(names)):
  if names[i] == 'anguilla(ecd)':
    names[i] = 'eastcaribbeandollar'
  if isinstance(names[i],str):    # this test needed only for python2
    ascii = unidecode(names[i])
  else:
    ascii = names[i]
  if names[i] != ascii:
    if not foundunicode:
      foundunicode = True
      outstr += '# Unicode Currency Names\n\n!utf8\n'
    outstr += names[i] + ' ' *(23-len(names[i])) + ascii + '\n'
    names[i] = ascii
if foundunicode:
  outstr += '!endutf8\n\n'

outstr += '# ISO Currency Codes\n\n'

outstr += '\n'.join([x + ' '*20 + y for x,y in zip(codes,names)])

usd = codes.index('USD')
euro = codes.index('EUR')
usdval = values[usd] 

values = ['1|' + x +' euro' for x in values]
values[euro] = usdval + ' US$'

del names[usd]
del values[usd]

# print rates here

now = datetime.now()
outstr += '\n\n# Currency exchange rates from Time Genie (www.timegenie.com)\n'
outstr += '\n!message Currency exchange rates from www.timegenie.com on '+now.strftime('%Y-%m-%d')+'\n\n'

maxlen = max(list(map(len,names))) + 2
outstr += '\n'.join([x.ljust(maxlen) + y for x,y in zip(names, values)])


# precious metals prices

outstr += '\n\n# Precious metals prices from http://services.packetizer.com/spotprices/\n\n'

try:
  spotprices = ET.parse(urllib.request.urlopen('http://services.packetizer.com/spotprices/?f=xml'))
except IOError as exc:
  sys.stderr.write('Error connecting to spotprices server. {0}\n'.format(exc))
  sys.exit(1)

metals = ['gold','platinum','silver']

for metal in metals:
  outstr += '{0}    {1} US$/troyounce\n'.format((metal+'price').ljust(15), spotprices.find(metal).text)

try:
  if outfile == '-':
    info = codecs.lookup('utf8')
    outfile = codecs.StreamReaderWriter(sys.stdout, info.streamreader, info.streamwriter)
  else:    
    outfile = codecs.open(outfile,'w','utf8')
except IOError as exc:
  sys.stderr.write('Unable to write to output file. {0}\n'.format(exc))
  sys.exit(1)

outfile.write(outstr.replace('\n',os.linesep))

# In python3, open(outfile,mode='w',encoding='utf8') should work
# and then the explicit newline handling won't be needed

[-- Attachment #3: Type: text/plain, Size: 219 bytes --]


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ANNOUNCEMENT] Updated: units 2.14-1
  2017-05-22 10:50 ` [ANNOUNCEMENT] Updated: units 2.14-1 Brian Inglis
@ 2017-05-22 18:09   ` Achim Gratz
  2017-05-22 19:58     ` Brian Inglis
  2017-05-22 18:38   ` Brian Inglis
  1 sibling, 1 reply; 7+ messages in thread
From: Achim Gratz @ 2017-05-22 18:09 UTC (permalink / raw)
  To: cygwin

Brian Inglis writes:
> Currency exchange rates are updated on every run of setup by a permanent
> postinstall script
> 	/etc/postinstall/zp_units_cur.sh
> running
> 	/usr/bin/units_cur

Can you please make that configurable by some file in /var/lib/units
that will prevent the perpetual postinstall script from even forking if
the user decides that this should not be updated?


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Waldorf MIDI Implementation & additional documentation:
http://Synth.Stromeko.net/Downloads.html#WaldorfDocs

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ANNOUNCEMENT] Updated: units 2.14-1
  2017-05-22 18:38   ` Brian Inglis
@ 2017-05-22 18:38     ` Ian Lambert via cygwin
  2017-05-22 20:45       ` Brian Inglis
  0 siblings, 1 reply; 7+ messages in thread
From: Ian Lambert via cygwin @ 2017-05-22 18:38 UTC (permalink / raw)
  To: Brian.Inglis, Brian Inglis, cygwin



On May 22, 2017 2:09:35 PM EDT, Brian Inglis <Brian.Inglis> wrote:
>On 2017-05-21 23:45, Brian Inglis wrote:
>> On 2017-04-27 13:20, Brian Inglis wrote:
>>> * units-2.14-1
>>>
>>> The Units program converts quantities 
>
>Timegenie.com cert has been renewed for another 3 months until August
>19
>and redeployed, so certs are valid and will no longer produce errors.

FYI, 

In /var/log/setup.log.full I see:

Error connecting to currency server. <urlopen error [Errno 8] Name or service not known>

Running /usr/bin/units_cur or /etc/postinstall/zp_units_cur.sh I get

Error connecting to currency server. HTTP Error 407: Proxy Authentication Required

I'm behind a proxy requiring username, password, and restrictions on user-agents...


-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ANNOUNCEMENT] Updated: units 2.14-1
  2017-05-22 10:50 ` [ANNOUNCEMENT] Updated: units 2.14-1 Brian Inglis
  2017-05-22 18:09   ` Achim Gratz
@ 2017-05-22 18:38   ` Brian Inglis
  2017-05-22 18:38     ` Ian Lambert via cygwin
  1 sibling, 1 reply; 7+ messages in thread
From: Brian Inglis @ 2017-05-22 18:38 UTC (permalink / raw)
  To: cygwin

On 2017-05-21 23:45, Brian Inglis wrote:
> On 2017-04-27 13:20, Brian Inglis wrote:
>> * units-2.14-1
>>
>> The Units program converts quantities expressed in various scales to
>> their equivalents in other scales. The units program can handle
>> multiplicative scale changes as well as nonlinear conversions such as
>> Fahrenheit to Celsius or wire gauge. Units comes with an annotated,
>> extendable database defining over two thousand units.
>>
>> This is an update to the latest upstream release, which now supports
>> longer input expressions (e.g. a sum of more than 100 units), control
>> characters treated as white space to avoid producing errors about
>> invalid UTF-8, and includes 2980 units, 109 prefixes, and 96 nonlinear
>> units.

Timegenie.com cert has been renewed for another 3 months until August 19
and redeployed, so certs are valid and will no longer produce errors.

> Currency exchange rates are updated on every run of setup by a permanent
> postinstall script
> 	/etc/postinstall/zp_units_cur.sh
> running
> 	/usr/bin/units_cur
> to access
> 	https://rss.timegenie.com
> which uses HSTS to enforce https access, and whose security certificate
> has expired, so runs will fail with message:
> Error connecting to currency server. <urlopen error [SSL:
> CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)>
> 
> If this causes you problems, please temporarily rename the current
> update script /usr/bin/units_cur and replace by the attached, or replace
> the line between the first try: and except ...: by the following lines:
> [the first line is a comment, the remainder are indented two spaces]
> 
> #
> http://stackoverflow.com/questions/36600583/python-3-urllib-ignore-ssl-certificate-verification
>   import ssl
>   ctx = ssl.create_default_context()
>   ctx.check_hostname = False
>   ctx.verify_mode = ssl.CERT_NONE
>   currencies =
> ET.parse(urllib.request.urlopen('https://rss.timegenie.com/forex.xml',context=ctx)).findall('data')
> 
> to ignore the security certificate expiry until it is renewed (hopefully
> by sometime Tuesday after the holiday): when the security certificate
> has been renewed, I will follow up here to let everyone know.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ANNOUNCEMENT] Updated: units 2.14-1
  2017-05-22 18:09   ` Achim Gratz
@ 2017-05-22 19:58     ` Brian Inglis
  0 siblings, 0 replies; 7+ messages in thread
From: Brian Inglis @ 2017-05-22 19:58 UTC (permalink / raw)
  To: cygwin

On 2017-05-22 12:08, Achim Gratz wrote:
> Brian Inglis writes:
>> Currency exchange rates are updated on every run of setup by a permanent
>> postinstall script
>> 	/etc/postinstall/zp_units_cur.sh
>> running
>> 	/usr/bin/units_cur
> 
> Can you please make that configurable by some file in /var/lib/units
> that will prevent the perpetual postinstall script from even forking if
> the user decides that this should not be updated?

I'll take handling that, cert issue, and a proxy issue later in the
thread, upstream for discussion and follow up on apps.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ANNOUNCEMENT] Updated: units 2.14-1
  2017-05-22 18:38     ` Ian Lambert via cygwin
@ 2017-05-22 20:45       ` Brian Inglis
  0 siblings, 0 replies; 7+ messages in thread
From: Brian Inglis @ 2017-05-22 20:45 UTC (permalink / raw)
  To: cygwin

On 2017-05-22 12:38, Ian Lambert wrote:
> On May 22, 2017 2:09:35 PM EDT, Brian Inglis wrote:
>> On 2017-05-21 23:45, Brian Inglis wrote:
>>> On 2017-04-27 13:20, Brian Inglis wrote:
>>>> * units-2.14-1
>>>> The Units program converts quantities 
>> Timegenie.com cert has been renewed for another 3 months until
>> August 19 and redeployed, so certs are valid and will no longer
>> produce errors.
> In /var/log/setup.log.full I see:
> Error connecting to currency server. <urlopen error [Errno 8] Name or service not known>
> Running /usr/bin/units_cur or /etc/postinstall/zp_units_cur.sh I get
> Error connecting to currency server. HTTP Error 407: Proxy Authentication Required
> I'm behind a proxy requiring username, password, and restrictions on user-agents...

I'll take handling that, cert issue, and config issue upthread, upstream
for discussion, follow up on cygwin-apps, and report back here, or
provide a package update.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ANNOUNCEMENT] Updated: units 2.14-1
@ 2017-04-28 17:17 Brian Inglis
  0 siblings, 0 replies; 7+ messages in thread
From: Brian Inglis @ 2017-04-28 17:17 UTC (permalink / raw)
  To: cygwin

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
tion:

* units-2.14-1

The Units program converts quantities expressed in various scales to
their equivalents in other scales. The units program can handle
multiplicative scale changes as well as nonlinear conversions such as
Fahrenheit to Celsius or wire gauge. Units comes with an annotated,
extendable database defining over two thousand units.

This is an update to the latest upstream release, which now supports
longer input expressions (e.g. a sum of more than 100 units), control
characters treated as white space to avoid producing errors about
invalid UTF-8, and includes 2980 units, 109 prefixes, and 96 nonlinear
units.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-05-22 19:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <auto-000002683205@fwd1.webnames.ca>
2017-05-22 10:50 ` [ANNOUNCEMENT] Updated: units 2.14-1 Brian Inglis
2017-05-22 18:09   ` Achim Gratz
2017-05-22 19:58     ` Brian Inglis
2017-05-22 18:38   ` Brian Inglis
2017-05-22 18:38     ` Ian Lambert via cygwin
2017-05-22 20:45       ` Brian Inglis
2017-04-28 17:17 Brian Inglis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).