self.info("Uploading code")
dst = os.path.join(self.app_home, "code")
- self.node.upload(code, dst, overwrite = False, text = True)
+ self.node.upload(code, dst, overwrite = False, text = True, executable = True)
def upload_stdin(self, stdin = None):
if not stdin:
import collections
import os
+import stat
import random
import re
import tempfile
return (out, err), proc
def upload(self, src, dst, text = False, overwrite = True,
- raise_on_error = True):
+ raise_on_error = True, executable = False):
""" Copy content to destination
src string with the content to copy. Can be:
dst string with destination path on the remote host (remote is
always self.host)
- text src is text input, it must be stored into a temp file before
- uploading
+ when src is text input, it gets stored into a temp file before
+ uploading; in this case, and if executable is True, said temp file
+ is made executable, and thus uploaded file will be too
"""
# If source is a string input
f = None
f = tempfile.NamedTemporaryFile(mode=mode, delete=False)
f.write(src)
f.close()
+ if executable:
+ # do something like chmod u+x
+ mode = os.stat(f.name).st_mode
+ mode |= stat.S_IXUSR
+ os.chmod(f.name, mode)
+
src = f.name
# If dst files should not be overwritten, check that the files do not