I'm pretty sure hooks execute in the parent directory. So if you have charm/ hooks/ db-relation-changed myfiles/ test.yaml
you need to open("hooks/myfiles/test.yaml") John =:-> On Jul 20, 2017 04:58, "fengxia" <fx...@lenovo.com> wrote: > Hi Juju, > > I think I read at some point in the official document that you can't set > state from hook. > > However, this is what I'm trying to achieve: in @hook('config-changed'), I > will pass in a file path as a config value. Files are part of the charm so > they are installed in /var/lib/juju/agents/unit-mycharm/myfiles/ on the > unit node. But when @hook('config-changed') is triggered, my code to > "open('/path/file')" actually complains "file not found". This makes me > wonder that hook is not visible of the charm directory? > > So I'm thinking this can be worked around if I set_state("mystate") from > hook. But doing so didn't trigger @when("mystate"). > > What's the right way to do this then? > > -- > Feng xia > Engineer > Lenovo USA > > Phone: 5088011794 > fx...@lenovo.com > > Lenovo.com > Twitter | Facebook | Instagram | Blogs | Forums > > > -- > Juju mailing list > Juju@lists.ubuntu.com > Modify settings or unsubscribe at: https://lists.ubuntu.com/mailm > an/listinfo/juju >
-- Juju mailing list Juju@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/juju