Jupyter Notebook和md5sum是否存在任何已知问题?

时间:2020-05-21 18:10:37

标签: jupyter-notebook pipe

我错过了让笔记本使用管道并在提供的文件上返回md5sum的步骤吗?

目前,在我的计算机(Mac)上,对于 Think Python

downloadUrl("./MapStolenDAO.php", function(data) {
  var xml = data.responseXML;
  var markers = xml.documentElement.getElementsByTagName('marker');
  const mapMarkers = markers.map((markerElem) => {
    var id = markerElem.getAttribute('id');
    var address = markerElem.getAttribute('address');
    var time = markerElem.getAttribute('time');
    var point = new google.maps.LatLng(
        parseFloat(markerElem.getAttribute('lat')),
        parseFloat(markerElem.getAttribute('lng')));

    var infowincontent = document.createElement('div');
    var strong = document.createElement('strong');
    strong.textContent = address
    infowincontent.appendChild(strong);
    infowincontent.appendChild(document.createElement('br'));

    var time = document.createElement('timestamp');
    time.timestampContent = time
    infowincontent.appendChild(Time);
    var labels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
    var marker = new google.maps.Marker({
        position: point,
        label: labels[i % labels.length]
    });

    marker.addListener('click', function() {
      infoWindow.setContent(infowincontent);
      infoWindow.open(map, marker);
    });
    return marker;
  });
  var markerCluster = new MarkerClusterer(map, mapMarkers,
      {imagePath: './mapImages'});
  });
});

1 个答案:

答案 0 :(得分:0)

在下面回答自己

我已经意识到这个问题与Jupyter Notebook本身无关。 Mac OS X,默认情况下未安装md5sum,但是它提供了等效的工具md5。要计算文件的128位MD5哈希,请运行以下命令:

md5 file.ext

该命令返回128位md5哈希

上面最初使用的代码现在看起来像这样。

def pipe(cmd):
     """Runs a command in a subprocess.

     cmd: string Unix command

     Returns (res, stat), the output of the subprocess and the exit status.
"""
     # Note: os.popen is deprecated
     # now, which means we are supposed to stop using it and start using
     # the subprocess module.  But for simple cases, I find
     # subprocess more complicated than necessary.  So I am going
     # to keep using os.popen until they take it away.

     fp = os.popen(cmd)
     res = fp.read()
     stat = fp.close()
     assert stat is None
     return res, stat

cmd= 'md5 ' + 'words.txt'
pipe(cmd)
相关问题