Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fdkutils] Improvements & coverage #946

Merged
merged 2 commits into from
Aug 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions python/afdko/fdkutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import subprocess
import tempfile

__version__ = '1.3.5'
__version__ = '1.3.6'


def validate_path(path_str):
Expand Down Expand Up @@ -98,6 +98,10 @@ def run_shell_command_logging(args):
if out:
print(out.decode())
if proc.poll() is not None:
if proc.returncode != 0: # must be called *after* poll()
msg = " ".join(args)
print(f"Error executing command '{msg}'")
return False
out = proc.stdout.readline().rstrip()
if out:
print(out.decode())
Expand Down Expand Up @@ -133,39 +137,50 @@ def get_shell_command_output(args, std_error=False):
return success, str_output


def runShellCmd(cmd):
def runShellCmd(cmd, shell=True, timeout=None):
try:
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
p = subprocess.Popen(cmd, shell=shell, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stdoutdata, _ = p.communicate()
stdoutdata, _ = p.communicate(timeout=timeout)
str_output = stdoutdata.decode('utf-8', 'backslashreplace')

if p.returncode != 0: # must be called *after* communicate()
print(f"Error executing command '{cmd}'\n{str_output}")
str_output = ""

except subprocess.TimeoutExpired as err:
p.kill()
print(f"{err}") # the 'err' will contain the command
str_output = ""

except (subprocess.CalledProcessError, OSError) as err:
msg = f"Error executing command '{cmd}'\n{err}"
print(msg)
print(f"Error executing command '{cmd}'\n{err}")
str_output = ""

return str_output


def runShellCmdLogging(cmd):
def runShellCmdLogging(cmd, shell=True):
try:
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
proc = subprocess.Popen(cmd, shell=shell, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
while 1:
output = proc.stdout.readline().rstrip()
if output:
print(output.decode('utf-8', 'backslashreplace'))

if proc.poll() is not None:
if proc.returncode != 0: # must be called *after* poll()
print(f"Error executing command '{cmd}'")
return 1

output = proc.stdout.readline().rstrip()
if output:
print(output.decode('utf-8', 'backslashreplace'))
break

except (subprocess.CalledProcessError, OSError) as err:
msg = f"Error executing command '{cmd}'\n{err}"
print(msg)
print(f"Error executing command '{cmd}'\n{err}")
return 1

return 0
Empty file.
Binary file added tests/fdkutils_data/input/font.cff
Binary file not shown.
Binary file added tests/fdkutils_data/input/font.otf
Binary file not shown.
68 changes: 68 additions & 0 deletions tests/fdkutils_data/input/font.pfa

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added tests/fdkutils_data/input/font.pfb
Binary file not shown.
Binary file added tests/fdkutils_data/input/font.ps
Binary file not shown.
Binary file added tests/fdkutils_data/input/font.ttf
Binary file not shown.
166 changes: 166 additions & 0 deletions tests/fdkutils_data/input/font.ufo/fontinfo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ascender</key>
<integer>712</integer>
<key>capHeight</key>
<integer>656</integer>
<key>copyright</key>
<string>Copyright 2010, 2012, 2014 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'.</string>
<key>descender</key>
<integer>-205</integer>
<key>familyName</key>
<string>Source Sans Pro</string>
<key>guidelines</key>
<array>
</array>
<key>italicAngle</key>
<integer>0</integer>
<key>openTypeHheaAscender</key>
<integer>984</integer>
<key>openTypeHheaDescender</key>
<integer>-273</integer>
<key>openTypeHheaLineGap</key>
<integer>0</integer>
<key>openTypeNameDesigner</key>
<string>Paul D. Hunt</string>
<key>openTypeNameLicense</key>
<string>This Font Software is licensed under the SIL Open Font License, Version 1.1. This license is available with a FAQ at: http://scripts.sil.org/OFL. This Font Software is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the SIL Open Font License for the specific language, permissions and limitations governing your use of this Font Software.</string>
<key>openTypeNameLicenseURL</key>
<string>http://scripts.sil.org/OFL</string>
<key>openTypeNameManufacturer</key>
<string>Adobe Systems Incorporated</string>
<key>openTypeNameManufacturerURL</key>
<string>http://www.adobe.com/type</string>
<key>openTypeOS2CodePageRanges</key>
<array>
<integer>0</integer>
<integer>1</integer>
<integer>2</integer>
<integer>3</integer>
<integer>4</integer>
<integer>7</integer>
<integer>8</integer>
<integer>29</integer>
</array>
<key>openTypeOS2Panose</key>
<array>
<integer>2</integer>
<integer>11</integer>
<integer>5</integer>
<integer>3</integer>
<integer>3</integer>
<integer>4</integer>
<integer>3</integer>
<integer>2</integer>
<integer>2</integer>
<integer>4</integer>
</array>
<key>openTypeOS2Type</key>
<array>
</array>
<key>openTypeOS2TypoAscender</key>
<integer>750</integer>
<key>openTypeOS2TypoDescender</key>
<integer>-250</integer>
<key>openTypeOS2TypoLineGap</key>
<integer>0</integer>
<key>openTypeOS2UnicodeRanges</key>
<array>
<integer>0</integer>
<integer>1</integer>
<integer>2</integer>
<integer>4</integer>
<integer>5</integer>
<integer>6</integer>
<integer>7</integer>
<integer>9</integer>
<integer>29</integer>
<integer>30</integer>
<integer>32</integer>
<integer>57</integer>
</array>
<key>openTypeOS2VendorID</key>
<string>ADBO</string>
<key>openTypeOS2WinAscent</key>
<integer>984</integer>
<key>openTypeOS2WinDescent</key>
<integer>273</integer>
<key>postscriptBlueFuzz</key>
<integer>0</integer>
<key>postscriptBlueScale</key>
<real>0.0625</real>
<key>postscriptBlueValues</key>
<array>
<integer>-12</integer>
<integer>0</integer>
<integer>486</integer>
<integer>498</integer>
<integer>518</integer>
<integer>530</integer>
<integer>574</integer>
<integer>586</integer>
<integer>638</integer>
<integer>650</integer>
<integer>656</integer>
<integer>668</integer>
<integer>712</integer>
<integer>724</integer>
</array>
<key>postscriptFamilyBlues</key>
<array>
<integer>-12</integer>
<integer>0</integer>
<integer>486</integer>
<integer>498</integer>
<integer>518</integer>
<integer>530</integer>
<integer>574</integer>
<integer>586</integer>
<integer>638</integer>
<integer>650</integer>
<integer>656</integer>
<integer>668</integer>
<integer>712</integer>
<integer>724</integer>
</array>
<key>postscriptFamilyOtherBlues</key>
<array/>
<key>postscriptFontName</key>
<string>SourceSansPro-Regular</string>
<key>postscriptForceBold</key>
<false/>
<key>postscriptOtherBlues</key>
<array>
<integer>-217</integer>
<integer>-205</integer>
</array>
<key>postscriptStemSnapH</key>
<array>
<integer>67</integer>
<integer>78</integer>
</array>
<key>postscriptStemSnapV</key>
<array>
<integer>84</integer>
<integer>95</integer>
</array>
<key>postscriptUnderlinePosition</key>
<integer>-75</integer>
<key>postscriptUnderlineThickness</key>
<integer>50</integer>
<key>styleName</key>
<string>Regular</string>
<key>trademark</key>
<string>Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries.</string>
<key>unitsPerEm</key>
<integer>1000</integer>
<key>versionMajor</key>
<integer>2</integer>
<key>versionMinor</key>
<integer>20</integer>
<key>xHeight</key>
<integer>486</integer>
</dict>
</plist>
54 changes: 54 additions & 0 deletions tests/fdkutils_data/input/font.ufo/glyphs/_notdef.glif
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<glyph name=".notdef" format="2">
<advance width="653"/>
<outline>
<contour>
<point x="89" y="0" type="line"/>
<point x="565" y="0" type="line"/>
<point x="565" y="660" type="line"/>
<point x="89" y="660" type="line"/>
</contour>
<contour>
<point x="197" y="58" type="line"/>
<point x="271" y="190" type="line"/>
<point x="325" y="293" type="line"/>
<point x="329" y="293" type="line"/>
<point x="381" y="190" type="line"/>
<point x="454" y="58" type="line"/>
</contour>
<contour>
<point x="325" y="387" type="line"/>
<point x="275" y="481" type="line"/>
<point x="209" y="600" type="line"/>
<point x="444" y="600" type="line"/>
<point x="378" y="481" type="line"/>
<point x="329" y="387" type="line"/>
</contour>
<contour>
<point x="154" y="110" type="line"/>
<point x="154" y="572" type="line"/>
<point x="281" y="340" type="line"/>
</contour>
<contour>
<point x="498" y="110" type="line"/>
<point x="372" y="340" type="line"/>
<point x="498" y="572" type="line"/>
</contour>
</outline>
<lib>
<dict>
<key>com.adobe.type.autohint.v2</key>
<dict>
<key>hintSetList</key>
<array/>
</dict>
<key>public.postscript.hints</key>
<dict>
<key>formatVersion</key>
<string>1</string>
<key>hintSetList</key>
<array/>
</dict>
</dict>
</lib>
</glyph>
Loading