I’m using Fabric for project management, deployment, etc. I don’t really understand the more convenient way to run commands. For example, considering I don’t care of capture and shell arguments of Fabric local function, which are pros/cons of the following?
os.mkdir(path)
VS
local("mkdir %s" % path)
Depending on the goals of your project, either may be slightly more appropriate. Here are some pros and cons.
locallocalandrunorsudoas your project changesrunandsudoI think simple
localcommands that can easily be represented using standard library functions should be written just using the standard library as a default choice due to lower complexity. Case by case, I’d ask myself which is more likely: running thisfabfile.pyprogram on different OSes or converting this command from a local to a remote command and then code as calls tolocalif the latter is more likely.