Use file copy instead of symlink on Windows

This commit is contained in:
Marek Marczykowski-Górecki 2013-07-30 11:27:46 +02:00
parent 467477409d
commit 4ae720956d
2 changed files with 21 additions and 7 deletions

View File

@ -392,8 +392,12 @@ class QubesVm(object):
os.remove(self.icon_path)
except:
pass
os.symlink (new_label.icon_path, self.icon_path)
subprocess.call(['sudo', 'xdg-icon-resource', 'forceupdate'])
if hasattr(os, "symlink"):
os.symlink (new_label.icon_path, self.icon_path)
# FIXME: some os-independent wrapper?
subprocess.call(['sudo', 'xdg-icon-resource', 'forceupdate'])
else:
shutil.copy(new_label.icon_path, self.icon_path)
# fire hooks
for hook in self.hooks_label_setter:
@ -1106,7 +1110,10 @@ class QubesVm(object):
if verbose:
print >> sys.stderr, "--> Creating icon symlink: {0} -> {1}".format(self.icon_path, self.label.icon_path)
os.symlink (self.label.icon_path, self.icon_path)
if hasattr(os, "symlink"):
os.symlink (self.label.icon_path, self.icon_path)
else:
shutil.copy(self.label.icon_path, self.icon_path)
# fire hooks
for hook in self.hooks_create_on_disk:

View File

@ -29,6 +29,7 @@ import subprocess
import stat
import sys
import re
import shutil
import stat
from qubes.qubes import QubesVm,register_qubes_vm_class,vmm,dry_run
@ -198,10 +199,6 @@ class QubesHVm(QubesVm):
print >> sys.stderr, "--> Creating directory: {0}".format(self.dir_path)
os.mkdir (self.dir_path)
if verbose:
print >> sys.stderr, "--> Creating icon symlink: {0} -> {1}".format(self.icon_path, self.label.icon_path)
os.symlink (self.label.icon_path, self.icon_path)
self.create_config_file()
# create empty disk
@ -233,6 +230,16 @@ class QubesHVm(QubesVm):
if retcode != 0:
raise IOError ("Error while copying {0} to {1}".\
format(template_priv, self.private_img))
if verbose:
print >> sys.stderr, "--> Creating icon symlink: {0} -> {1}".format(self.icon_path, self.label.icon_path)
try:
if hasattr(os, "symlink"):
os.symlink (self.label.icon_path, self.icon_path)
else:
shutil.copy(self.label.icon_path, self.icon_path)
except Exception as e:
print >> sys.stderr, "WARNING: Failed to set VM icon: %s" % str(e)
# fire hooks
for hook in self.hooks_create_on_disk: