googlefonts / pyfontaine

Python tool to check font files for language/character set support
https://github.com/googlefonts/pyfontaine
GNU General Public License v3.0
104 stars 20 forks source link

Run offline #38

Closed davelab6 closed 9 years ago

davelab6 commented 10 years ago

After installing pyfontaine v1.1.5 then trying to use it for the first time offline, it wouldn’t run giving a fatal error:

$ pyfontaine googlefontdirectory/ofl/rubikone/RubikOne-Regular.ttf
WARNING: Please install [PyICU](https://pypi.python.org/pypi/PyICU)
Traceback (most recent call last):
  File "/usr/local/bin/pyfontaine", line 117, in <module>
    main()
  File "/usr/local/bin/pyfontaine", line 113, in main
    tree = director.construct_tree(fonts)
  File "/usr/local/lib/python2.7/site-packages/fontaine/builder.py", line 132, in construct_tree
    in font.get_orthographies():
  File "/usr/local/lib/python2.7/site-packages/fontaine/font.py", line 173, in get_orthographies
    for charmap in library.charmaps:
  File "/usr/local/lib/python2.7/site-packages/fontaine/cmap.py", line 45, in charmaps
    for charmap_klass in module.Extension.get_charmaps():
  File "/usr/local/lib/python2.7/site-packages/fontaine/ext/extensis.py", line 22, in __getcharmaps__
    for ext in Extension.get_codepoints():
  File "/usr/local/lib/python2.7/site-packages/fontaine/ext/extensis.py", line 46, in get_codepoints
    path = get_from_cache('languages.xml', EXTENSIS_LANG_XML)
  File "/usr/local/lib/python2.7/site-packages/fontaine/ext/update.py", line 36, in get_from_cache
    if not op.exists(filepath) and not get_file(filepath, url):
  File "/usr/local/lib/python2.7/site-packages/fontaine/ext/update.py", line 26, in get_file
    r = requests.get(url)
  File "/usr/local/lib/python2.7/site-packages/requests/api.py", line 55, in get
    return request('get', url, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/requests/api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 456, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 559, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/requests/adapters.py", line 375, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='raw.github.com', port=443): Max retries exceeded with url: /davelab6/extensis-languages/master/languages.xml (Caused by <class 'socket.gaierror'>: [Errno 8] nodename nor servname provided, or not known)

Every charset that is fetched from the web should be requested with a try: and if there is an exception (such as requests.exceptions.ConnectionError) then it should print a warning (like WARNING: Please run pyfontaine with an active internet connection to download all character maps) and continue to work using the char maps it has.

Or, ideally, it would fetch all the charmaps during installation. Is this possible?

vitalyvolkov commented 10 years ago

I have created new release with changes for that issue. Updated 1.1.5 now is on PyPi also available

https://github.com/davelab6/pyfontaine/releases/tag/1.1.5-1

davelab6 commented 9 years ago

Does it fetch all the charmaps during installation?

vitalyvolkov commented 9 years ago

It should, see MANIFEST.in

davelab6 commented 9 years ago

I mean the external ones? The readme says,

Additional definitions are downloaded from the Extensis, font-config and Unicode websites.

are they first fetched at installation or first run?

davelab6 commented 9 years ago

Also, lets host the Extensis file ourselves; I know they are not going to update it, as the guy who maintained it left the company

vitalyvolkov commented 9 years ago

I mean the external ones? The readme says,

Additional definitions are downloaded from the Extensis, font-config and Unicode websites.

are they first fetched at installation or first run?

When you first run application they will be downloaded into user local directory and then each time you run application those files are read from that place.

vitalyvolkov commented 9 years ago

To clarify

When installing pyfontaine you do not have any data files. But after you run application first time latest files will be downloaded to user local directory and all data read from there next time.

In case you do not have internet connection those files are copied from pyfontaine internal package (see https://github.com/davelab6/pyfontaine/tree/master/fontaine/ext/data) to user local directory.

davelab6 commented 9 years ago

okay, sounds good, I'll test :)