diff options
Diffstat (limited to 'humblebundle/fetch-humble-bundle/default.nix')
-rw-r--r-- | humblebundle/fetch-humble-bundle/default.nix | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/humblebundle/fetch-humble-bundle/default.nix b/humblebundle/fetch-humble-bundle/default.nix index 36601bd1..c37e2043 100644 --- a/humblebundle/fetch-humble-bundle/default.nix +++ b/humblebundle/fetch-humble-bundle/default.nix @@ -21,6 +21,8 @@ propagatedBuildInputs = with pythonPackages; [ requests2 ]; }; + pyStr = str: "'${stdenv.lib.escape ["'" "\\"] str}'"; + getDownloadURL = writeText "gethburl.py" '' import sys, humblebundle @@ -38,32 +40,33 @@ def find_download(downloads): for machine_name, dstruct in sum(downloads.values(), []): - if machine_name == '${machineName}': + if machine_name == ${pyStr machineName}: for ds in dstruct: - if ds.name == '${downloadName}': + if ds.name == ${pyStr downloadName}: return ds print >>sys.stderr, \ - 'Unable to find ${downloadName} for ${machineName}!' + ${pyStr "Unable to find ${downloadName} for ${machineName}!"} print >>sys.stderr, 'Available download types:' for ds in dstruct: print >>sys.stderr, " " + ds.name raise SystemExit(1) hb = humblebundle.HumbleApi() - hb.login('${email}', '${password}') + hb.login(${pyStr email}, ${pyStr password}) products = dict(get_products(hb)) dstruct = find_download(products) if dstruct is None: - print >>sys.stderr, 'Cannot find download for ${machineName}!' + print >>sys.stderr, ${pyStr "Cannot find download for ${machineName}!"} print >>sys.stderr, 'Available machine names:' for name, dstructs in sorted(products.items(), key=lambda x: x[0]): print >>sys.stderr, " * " + name print >>sys.stderr, " " + ', '.join(map(lambda x: x[0], dstructs)) raise SystemExit(1) - elif dstruct.md5 != '${md5}': + elif dstruct.md5 != ${pyStr md5}: print >>sys.stderr, \ - 'MD5 for ${machineName} is not ${md5} but ' + dstruct.md5 + '.' + ${pyStr "MD5 for ${machineName} is not ${md5} but "} \ + + dstruct.md5 + '.' raise SystemExit(1) else: print dstruct.url.web |