Ubuntu 加密主目录 |Errno 36 文件名太长 [英] Ubuntu encrypted home directory | Errno 36 File Name too long

查看:40
本文介绍了Ubuntu 加密主目录 |Errno 36 文件名太长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 python 抓取工具/蜘蛛程序时遇到了一个超过字符限制的 URL,标题为 IOError.使用 httplib2 并且当我尝试检索 URL 时,我收到一个文件名太长错误.我更喜欢将我的所有项目都放在主目录中,因为我使用的是 Dropbox.无论如何解决这个问题,还是我应该在家外设置我的工作目录?

解决方案

过长的文件名以 '.cache/www.example.com' 开头这一事实说明了问题所在.

httplib2 可选择缓存您发出的请求.您已启用缓存,并将其指定为 .cache 作为缓存目录.

简单的解决方案是将缓存目录放在其他地方.

如果没有看到您的代码,就不可能告诉您如何修复它.但这应该是微不足道的.FileCache 的文档显示它需要一个 dir_name 作为第一个参数.

或者,您可以传递一个 safe 函数,让您从 URI 生成文件名,覆盖默认值.这将允许您生成适合 Ubuntu 加密 fs 的 144 个字符限制的文件名.

或者,您也可以使用与 FileCache 相同的接口创建自己的对象,并将其传递给 Http 对象以用作缓存.例如,您可以使用 tempfile 创建随机文件名,并将 URL 到文件名的映射存储在 anydbmsqlite3 数据库中.>

当然,最后一种选择是关闭缓存.

Working on a python scraper/spider and encountered a URL that exceeds the char limit with the titled IOError. Using httplib2 and when I attempt to retrieve the URL I receive a file name too long error. I prefer to have all of my projects within the home directory since I am using Dropbox. Anyway around this issue or should I just setup my working directory outside of home?

解决方案

The fact that the filename that's too long starts with '.cache/www.example.com' explains the problem.

httplib2 optionally caches requests that you make. You've enabled caching, and you've given it .cache as the cache directory.

The easy solution is to put the cache directory somewhere else.

Without seeing your code, it's impossible to tell you how to fix it. But it should be trivial. The documentation for FileCache shows that it takes a dir_name as the first parameter.

Or, alternatively, you can pass a safe function that lets you generate a filename from the URI, overriding the default. That would allow you to generate filenames that fit within the 144-character limit for Ubuntu encrypted fs.

Or, alternatively, you can create your own object with the same interface as FileCache and pass that to the Http object to use as a cache. For example, you could use tempfile to create random filenames, and store a mapping of URLs to filenames in an anydbm or sqlite3 database.

A final alternative is to just turn off caching, of course.

这篇关于Ubuntu 加密主目录 |Errno 36 文件名太长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆