ERL in corp app for fortage
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

26 lines
767 B

  1. % Port ScanPorttage dirs
  2. -module(ScanPortage).
  3. -export([run/1]).
  4. run() ->
  5. Port = open_port({spawn, "python3 ./site/include/scanPortage.py"},
  6. [{line, 80}, exit_status, stderr_to_stdout, in, binary]),
  7. run(Port, [], <<>>).
  8. run(Port, Lines, OldLine) ->
  9. receive
  10. {Port, {data, Data}} ->
  11. case Data of
  12. {eol, Line} ->
  13. run(Port, [<<OldLine/binary,Line/binary>> | Lines], <<>>);
  14. {noeol, Line} ->
  15. run(Port, Lines, <<OldLine/binary,Line/binary>>)
  16. end;
  17. {Port, {exit_status, 0}} ->
  18. {ok, Lines};
  19. {Port, {exit_status, Status}} ->
  20. {error, Status, Lines}
  21. after
  22. 30000 ->
  23. {error, timeout}
  24. end.