<s> import os <EOL> from biicode . client . exception import ClientException <EOL> from biicode . client . command . process_executor import execute <EOL> class RaspberryPi ( object ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , user_io , paths , hive_disk_image ) : <EOL> self . user_io = user_io <EOL> self . paths = paths <EOL> self . hive_disk_image = hive_disk_image <EOL> def sync_dinlib ( self ) : <EOL> """<STR_LIT>""" <EOL> user , ip , _ , _ = self . _rpi_settings <EOL> hive_lib_path = os . path . join ( self . paths . hive , "<STR_LIT>" ) <EOL> command = "<STR_LIT>" . format ( user , ip , <EOL> hive_lib_path ) <EOL> rsync_status , _ = execute ( command , self . user_io ) <EOL> if rsync_status : <EOL> self . user_io . out . error ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> @ property <EOL> def _rpi_settings ( self ) : <EOL> try : <EOL> rpi = self . hive_disk_image . settings . rpi <EOL> return rpi . user , rpi . ip , rpi . directory <EOL> except Exception as e : <EOL> raise ClientException ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % str ( e ) ) <EOL> def send_sync ( self ) : <EOL> '''<STR_LIT>''' <EOL> bin_dir = self . paths . bin <EOL> user , ip , directory = self . _rpi_settings <EOL> rpi_directory = '<STR_LIT>' % ( directory , self . paths . project_name ) <EOL> command = ( '<STR_LIT>' <EOL> % ( rpi_directory , bin_dir , user , ip , rpi_directory ) ) <EOL> self . user_io . out . info ( '<STR_LIT>' % command ) <EOL> try : <EOL> _ , out = execute ( command , self . user_io , cwd = bin_dir ) <EOL> if out : <EOL> self . user_io . out . info ( "<STR_LIT:%s>" % out ) <EOL> except Exception as e : <EOL> raise ClientException ( '<STR_LIT>' <EOL> '<STR_LIT>' % str ( e ) ) <EOL> def ssh ( self ) : <EOL> user , ip , _ = self . _rpi_settings <EOL> command = ( '<STR_LIT>' % ( user , ip ) ) <EOL> self . user_io . out . info ( '<STR_LIT>' % command ) <EOL> _ , out = execute ( command , self . user_io ) <EOL> self . user_io . out . info ( "<STR_LIT:%s>" % out ) </s>
