MCPcopy Create free account
hub / github.com/aws/aws-cli / store_string

Method store_string

awscli/autoprompt/history.py:44–61  ·  view source on GitHub ↗
(self, string)

Source from the content-addressed store, hash-verified

42 return []
43
44 def store_string(self, string):
45 history = {'version': self.HISTORY_VERSION, 'commands': []}
46 try:
47 if os.path.exists(self.filename):
48 with open(self.filename) as f:
49 history = json.load(f)
50 elif not os.path.exists(os.path.dirname(self.filename)):
51 os.makedirs(os.path.dirname(self.filename))
52 history['commands'].append(string)
53 history['commands'] = history['commands'][-self._max_commands :]
54 with open(self.filename, 'w') as f:
55 json.dump(history, f)
56 try:
57 os.chmod(self.filename, 0o600)
58 except OSError as e:
59 LOG.debug('Unable to set file permissions for autoprompt history file: %s', e)
60 except Exception as e:
61 LOG.debug('Unable to save autoprompt history (check file permissions): %s', e)
62
63
64class HistoryCompleter(Completer):

Calls 4

existsMethod · 0.80
loadMethod · 0.45
makedirsMethod · 0.45
dumpMethod · 0.45