<s> import os , shutil , sys , textwrap <EOL> from . import Command <EOL> from arm . util import get_playbook_root <EOL> import argparse <EOL> from git import Repo as git_repo <EOL> from hgapi import Repo as hg_repo <EOL> class freeze ( Command ) : <EOL> help = "<STR_LIT>" <EOL> def __init__ ( self , parser ) : <EOL> parser . description = self . help <EOL> def run ( self , argv ) : <EOL> _root = get_playbook_root ( os . getcwd ( ) ) <EOL> if not _root : <EOL> print ( textwrap . dedent ( '''<STR_LIT>''' ) ) <EOL> return <NUM_LIT:1> <EOL> _roles_directory = os . path . join ( _root , '<STR_LIT>' ) <EOL> for _item in os . listdir ( _roles_directory ) : <EOL> _item = os . path . join ( _roles_directory , _item ) <EOL> if not os . path . islink ( _item ) : <EOL> continue <EOL> alias = None <EOL> if os . path . basename ( _item ) != os . path . basename ( os . path . realpath ( _item ) ) : <EOL> alias = os . path . basename ( _item ) <EOL> if os . path . exists ( os . path . join ( os . path . realpath ( _item ) , '<STR_LIT>' ) ) : <EOL> repo = git_repo ( os . path . realpath ( _item ) ) <EOL> origin = repo . remotes [ <NUM_LIT:0> ] . config_reader . config . get ( '<STR_LIT>' , '<STR_LIT:url>' ) <EOL> commit = repo . head . commit . hexsha <EOL> if not alias : <EOL> print "<STR_LIT>" % ( origin , commit ) <EOL> continue <EOL> print "<STR_LIT>" % ( origin , commit , alias ) <EOL> if os . path . exists ( os . path . join ( os . path . realpath ( _item ) , '<STR_LIT>' ) ) : <EOL> repo = hg_repo ( os . path . realpath ( _item ) ) <EOL> print repo <EOL> if not alias : <EOL> print "<STR_LIT>" % ( origin , commit ) <EOL> continue <EOL> print "<STR_LIT>" % ( origin , commit , alias ) </s>
