def run(command, *, argv=None, default_activate=None, **kwargs): """ Run the photons mainline with arguments as specified by the command. This will enable the "core" module and all it's dependencies by default. To load no modules by default use ``default_activate=[]``. If you want only specific modules, then use ``default_activate=["transport"]``. If you want all available photons modules to be activated, use ``default_activate=["__all__"]``. The command may look something like:: run("{TARGET|lan:env}:{@:1} {@:2:}") Which is the same as saying: .. code-block:: python target = os.environ.get("TARGET", "lan") main([f"{target}:{sys.argv[1]}"] + sys.argv[2:]]) Note that if you have something like:: "{TARGET:env}:transform -- '{"power": "on"}'" We will not try to format everything after the ``--`` """ if argv is not None: argv.insert(0, sys.argv[0]) if isinstance(command, str): command = CommandSplitter({"argv": argv or sys.argv}, command).split() if default_activate is None: default_activate = ["core"] return main(command, default_activate=default_activate, **kwargs)
""" Falling lines of pixels """, ) tile_dice_roll = Animator( TileDiceRollAnimation, TileDiceRollOptions, """ A dice roll """, ) tile_balls = Animator( TileBallsAnimation, TileBallsOptions, """ Bouncing balls """, ) for name, animator in Animations.animators(): locals()[name] = animator.make_action() if __name__ == "__main__": from photons_app.executor import main import sys main(["lan:tile_twinkles"] + sys.argv[1:])
from photons_app.actions import an_action from delfick_project.addons import addon_hook from delfick_project.norms import sb, dictobj class Wat(dictobj.Spec): one = dictobj.Field(format_into=sb.string_spec) two = dictobj.Field(format_into=sb.string_spec) @property def thing(self): return "{0}.{1}".format(self.one, self.two) @addon_hook() def __lifx__(collector, *args, **kwargs): collector.register_converters( {"wat": Wat.FieldSpec(formatter=MergedOptionStringFormatter)}) @an_action() async def do_the_thing(collector, target, reference, artifact, **kwargs): print(collector.configuration["wat"].thing) if __name__ == "__main__": from photons_app.executor import main main()
for name, options in daydusk.schedules.items(): command = [ lifx_script, "lan:transform", options.reference, *extra_script_args, "--", json.dumps(options.extra), ] command = " ".join([shlex.quote(part) for part in command]) job = cron.new(command=command, user="******") job.dow.on(*options.dow) job.minute.on(options.minute) job.hour.on(options.hour) if os.path.exists(cronfile): os.remove(cronfile) cron.write(cronfile) print(f"Created crontab at {cronfile}") if __name__ == "__main__": from photons_app.executor import main import sys main(["make_crontab"])