Accessing shared network folders in Erlang/Elixir -
has changed way erlang 20/ elixir 1.5 handle file paths network shared folders? in elixir app running on windows server, used able refer file paths include virtual drive names (e.g., v:) mapped shared network folders (eg., \server1\shared_folder), after upgrading erlang/elixir (it coincidence) doesn't seem recognize these file paths.
for instance, monitor.start_link(dirs: ["c:/data/"]) works, monitor.start_link(dirs: ["v:/data/"] doesn't.
in case helps, here monitor module.
defmodule finreporting.monitor use genserver alias finreporting.repo alias finreporting.appstate def start_link(args) genserver.start_link(__module__, args) end def init(args) {:ok, watcher_pid} = filesystem.start_link(args) filesystem.subscribe(watcher_pid) io.inspect(watcher_pid, label: "watcher pid") {:ok, %{watcher_pid: watcher_pid}} end def handle_info({:file_event, watcher_pid, {path, events}}, %{watcher_pid: watcher_pid}=state) callback(path, events) {:noreply, state} end def handle_info({:file_event, watcher_pid, :stop}, %{watcher_pid: watcher_pid}=state) callback(:stop) {:noreply, state} end # callback runs python module using erlport def callback(:stop) io.puts "stop" end def callback(file_path, events) case {file_path, events} {"e:\\reporting_temp\\data\\mls_alltrans\\alltrans - mls_postdate.txt", [:modified]} -> affix = file.stat!(file_path).mtime |> :calendar.universal_time_to_local_time |> ecto.datetime.from_erl() |> calendar.strftime.strftime!("%b %d (%a) %l:%m %p") result = appstate.changeset(%appstate{}, %{key: "alltrans_filechange_" <> affix, value: "downloaded"}) |> repo.insert case result {:ok, struct} -> io.inspect("inserted successfully") py_mls_upload() {:error, changeset} -> io.inspect("insert failed") end { _ , _ } -> io.inspect {file_path, events, "irrelevant"} end end defp py_mls_upload {:ok, pp} = :python.start([{:python_path, to_char_list(path.expand("lib/python_scripts"))}, {:python, 'python'}]) :python.call(pp, :mlsupload, :run, []) end end
Comments
Post a Comment