<s> import logging <EOL> import os <EOL> from freezer . utils import utils <EOL> from freezer . utils import winutils <EOL> def vss_create_shadow_copy ( windows_volume ) : <EOL> """<STR_LIT>""" <EOL> shadow_path = None <EOL> shadow_id = None <EOL> vss_delete_symlink ( windows_volume ) <EOL> with winutils . DisableFileSystemRedirection ( ) : <EOL> path = os . path . dirname ( os . path . abspath ( __file__ ) ) <EOL> script = '<STR_LIT>' . format ( path ) <EOL> ( out , err ) = utils . create_subprocess ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , script , '<STR_LIT>' , windows_volume ] ) <EOL> if err != '<STR_LIT>' : <EOL> raise Exception ( '<STR_LIT>' <EOL> '<STR_LIT>' . format ( windows_volume , err ) ) <EOL> for line in out . split ( '<STR_LIT:\n>' ) : <EOL> if '<STR_LIT>' in line : <EOL> shadow_path = line . split ( '<STR_LIT>' ) [ <NUM_LIT:1> ] . strip ( ) <EOL> if '<STR_LIT>' in line : <EOL> shadow_id = line . split ( '<STR_LIT:=>' ) [ <NUM_LIT:1> ] . strip ( ) . lower ( ) + '<STR_LIT:}>' <EOL> shadow_id = shadow_id [ <NUM_LIT:1> : ] <EOL> logging . info ( '<STR_LIT>' . <EOL> format ( shadow_id ) ) <EOL> return shadow_path , shadow_id <EOL> def vss_delete_shadow_copy ( shadow_id , windows_volume ) : <EOL> """<STR_LIT>""" <EOL> with winutils . DisableFileSystemRedirection ( ) : <EOL> cmd = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' . format ( shadow_id ) , '<STR_LIT>' ] <EOL> ( out , err ) = utils . create_subprocess ( cmd ) <EOL> if err != '<STR_LIT>' : <EOL> raise Exception ( '<STR_LIT>' <EOL> '<STR_LIT>' . format ( shadow_id , err ) ) <EOL> vss_delete_symlink ( windows_volume ) <EOL> logging . info ( '<STR_LIT>' . <EOL> format ( shadow_id ) ) <EOL> return True <EOL> def vss_delete_symlink ( windows_volume ) : <EOL> """<STR_LIT>""" <EOL> path = os . path . join ( windows_volume , '<STR_LIT>' ) <EOL> try : <EOL> if os . path . exists ( path ) : <EOL> os . rmdir ( path ) <EOL> except Exception : <EOL> logging . error ( '<STR_LIT>' . <EOL> format ( os . path . join ( windows_volume , <EOL> '<STR_LIT>' ) ) ) </s>
