Skip to content

Instantly share code, notes, and snippets.

@larssono
Created April 22, 2015 16:12
Show Gist options
  • Save larssono/d5212d555f3ea1d98ff0 to your computer and use it in GitHub Desktop.
Save larssono/d5212d555f3ea1d98ff0 to your computer and use it in GitHub Desktop.
This code in Synapse
def thisCodeInSynapse(parentId, file=None, description=''):
"""Determines the name of the file that the code is called from
and uploads that to Synapse returning the synapseId of created codeObject.
"""
#print inspect.getfile(inspect.currentframe())
#print os.path.abspath(inspect.getfile(inspect.currentframe()))
file = inspect.getfile(sys._getframe(1)) if file==None else file
#Make sure unallowed characters are striped out for the name
code= synapseclient.File(file, name=os.path.split(file)[-1], parent=parentId, description=description)
codeEntity = syn.store(code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment