def get_home_model(self): """Use shell model to return home_model --the home_model code changed between .82 and .84 sugar --so do the lookup differently depending on sugar version """ global home_model (major, minor, micro, release) = self.sugar_version() _logger.debug('sugar version %s' % minor) if minor and minor >= 84: _logger.debug('using jarabe') from jarabe.model import shell home_model = shell.get_model() else: if not '/usr/share/sugar/shell/' in sys.path: sys.path.append('/usr/share/sugar/shell/') import view.Shell instance = view.Shell.get_instance() home_model = instance.get_model().get_home() if home_model: return home_model else: _logger.error('failed to retrieve home model') return None return home_model
def remove_embeds_from_file(self, fullPath): text = '' try: f = open(fullPath, "r") for line in f: if line.find('PyDebugTemp') == -1: text += line _file = file(fullPath, 'w') _file.write(text) _file.close() except IOException, e: _logger.error('unable to rewrite%s Exception:%s' % (fullPath, e))
def write_pdbrc_file(self): fn = os.path.join(os.environ['HOME'],'.pdbrc') break_list = self.get_all_breakpoints() _logger.debug("writing %s breakpoints"%(len(break_list),)) try: fd = file(fn,'w') fd.write('#Print instance variables (usage "pi classInstance")\n') fd.write('alias pi for k in %1.__dict__.keys(): print "%1",k,"=",%1.__dict__[k]\n') fd.write('#Print insance variables in self\n') fd.write('alias ps pi self\n') for break_line in break_list: fd.write('break %s\n' % break_line) fd.close() except Exception,e: _logger.error('unable to write to %s exception:%s'%(fn,e,))
def update_metadata(self): obj = self._jobject #ipshell() if obj: md = obj.get_metadata() obj._file_path = None if md: log_dict(md, 'journal metadata') _logger.debug('write file Jobject passed to write:%s' % (obj.object_id, )) chunk = self.activity_dict.get('name', '') for key in self.activity_dict.keys(): if key == 'title' or key == 'activity': continue md[key] = self.activity_dict[key] md['title'] = 'PyDebug_' + chunk md['title_set_by_user'] = '******' md['bundle_id'] = 'org.laptop.PyDebug' try: pass #datastore.write(obj) except Exception, e: _logger.debug('datastore write exception %s' % e) else: _logger.error('no metadata in write_file')
chunk = self.activity_dict.get('name', '') for key in self.activity_dict.keys(): if key == 'title' or key == 'activity': continue md[key] = self.activity_dict[key] md['title'] = 'PyDebug_' + chunk md['title_set_by_user'] = '******' md['bundle_id'] = 'org.laptop.PyDebug' try: pass #datastore.write(obj) except Exception, e: _logger.debug('datastore write exception %s' % e) else: _logger.error('no metadata in write_file') else: _logger.error('no jobject in write_file') def init_activity_dict(self): self.activity_dict['version'] = '1' #try to disable the annoying save panel asking for new title self.activity_dict['title_set_by_user'] = '******' self.activity_dict['name'] = 'untitled' self.activity_dict['bundle_id'] = '' self.activity_dict['command'] = '' self.activity_dict['class'] = '' self.activity_dict['module'] = '' self.activity_dict['icon'] = '' self.activity_dict['activity_id'] = '' self.activity_dict['package'] = '' self.activity_dict['jobject _id'] = ''
bundle_info.bundle_id = bundle_id bundle_name = bundle_info.get_name() os.environ['SUGAR_BUNDLE_NAME'] = bundle_name os.environ['SUGAR_BUNDLE_ID'] = bundle_id if version and version >= 0.839: #do 0.84 stuff cmd_args = activityfactory.get_command(bundle_info) else: from sugar.activity.registry import get_registry registry = get_registry() registry.add_bundle(child_path) activity_list = registry.find_activity(bundle_id) if len(activity_list) == 0: _logger.error('Activity %s not found'%bundle_id) print 'Activity %s not found'%bundle_id exit(1) cmd_args = activityfactory.get_command(activity_list[0]) myprofile = profile.get_profile() myprofile.color = XoColor() _logger.debug('command args:%r'%cmd_args) #need to get activity root, but activity bases off of HOME which some applications need to change #following will not work if storage system changes with new OS #required because debugger needs to be able to change home so that foreign apps will work activity_root = os.path.join('/home/olpc/.sugar/default/',bundle_id) os.environ['SUGAR_ACTIVITY_ROOT'] = activity_root _logger.debug('sugar_activity_root set to %s'%activity_root)