MCPcopy Create free account
hub / github.com/StackStorm/st2 / read_file

Method read_file

st2client/st2client/commands/action.py:810–826  ·  view source on GitHub ↗

Read file content and return content as string / unicode. NOTE: It's only mean to be used to read non-binary files since API right now doesn't support passing binary data.

(file_path)

Source from the content-addressed store, hash-verified

808 action_ref_or_id = action.ref
809
810 def read_file(file_path):
811 """
812 Read file content and return content as string / unicode.
813
814 NOTE: It's only mean to be used to read non-binary files since API right now doesn't
815 support passing binary data.
816 """
817 if not os.path.exists(file_path):
818 raise ValueError('File "%s" doesn\'t exist' % (file_path))
819
820 if not os.path.isfile(file_path):
821 raise ValueError('"%s" is not a file' % (file_path))
822
823 with open(file_path, "rb") as fp:
824 content = fp.read()
825
826 return content.decode("utf-8")
827
828 def transform_object(value):
829 # Also support simple key1=val1,key2=val2 syntax

Callers 1

parseMethod · 0.80

Calls 2

existsMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected