내가 파이썬에서 맥 OS X에 DMG 디스크 이미지를 만드는 데 관심이 파이썬 스크립트에서 찾기 창에 배경을 설정하고 다음과 같은 솔루션을 가로 질러 왔을 때 : 그러나 How do I create a nice-looking DMG for Mac OS X using command-line tools?파일 길이 제한
, 나는 이상한로 실행하고 경로 길이와 관련된 문제. 'doesnotwork'라는 하나에서 실행하면 배경이 제대로 호출 디스크 이미지에서 설정 얻을 것이다
import os
import Image
for NAME in ['works', 'doesnotwork']:
if os.path.exists(NAME + '.dmg'):
os.remove(NAME + '.dmg')
if os.path.exists('/Volumes/' + NAME):
raise Exception("Need to eject /Volumes/%s first" % NAME)
nx = 256
ny = 256
image = Image.new("RGB", (nx, ny))
for i in range(nx):
for j in range(ny):
image.putpixel((i, j), (i, 0, j))
os.system('hdiutil create -volname %s -fs HFS+ -size 10m %s.dmg' % (NAME, NAME))
os.system('hdiutil attach -readwrite -noverify -noautoopen %s.dmg' % NAME)
os.mkdir('/Volumes/%s/.background' % NAME)
image.save('/Volumes/%s/.background/background.png' % NAME, 'PNG')
apple_script = """osascript<<END
tell application "Finder"
tell disk "%s"
open
set current view of container window to icon view
set toolbar visible of container window to false
set statusbar visible of container window to false
set the bounds of container window to {{100, 100, 355, 355}}
set theViewOptions to the icon view options of container window
set the background picture of theViewOptions to file ".background:background.png"
close
open
end tell
end tell
END""" % NAME
os.system(apple_script)
가 '작동', 그리고 다음 스크립트는 내 문제를 보여줍니다. 볼륨 이름은 5 자로 제한됩니다. 그러나 폴더의 이름을 줄이면 배경을 저장하는 데 사용됩니다 (예 : .background
대신 .bkg
으로 변경하면 더 긴 볼륨 이름을 사용할 수 있습니다. 이는 전체 경로의 길이와 관련된 문제임을 나타냅니다. 누구든지 경로 길이에 제한이 있다는 것을 어느 수준에서 알 수 있습니까? 임의로 긴 경로를 허용하는 해결 방법이 있습니까?
편집 : 나는 맥 OS 10.6를 사용하고 - 스크립트는 당신이 당신의 따옴표를 탈출해야 믿고 10.7
10.6.8 여기에서 스크립트가 올바르게 작동합니다. – nneonneo
수용 할 수있는 가장 긴 볼륨 이름을 정확히 나타낼 수 있습니까? – nneonneo
@nneonneo - 위의 예에서 "NAME"을 (를) 5 자 이상으로 만들 수 없습니다. ''.background''를''.back''으로 바꾸면 8을 넘지 않아도되고,''.b''로 바뀌면 9 이상으로 만들 수 있습니다. 이상한! 나는 또한 10.6으로 다른 기계에서 재현 할 수 없다. 무엇이 이것을 일으킬 수 있습니까? (필자는이 컴퓨터에서 FileVault를 사용합니다. 그 일을 할 수 있습니까?) – astrofrog