import lwsdk
import subprocess
import os
import sys

reload (lwsdk)

__author__      = 'Ernest Chan'
__date__        = 'March 2018'
__copyright__   = 'Copyright Uberware. All rights reserverd.'
__version__     = '1.0'
__maintainer__  = 'Uberware'
__email__       = 'support@uberware.net'
__status__      = '1.0'
__lwver__       = '2015'

lwSI = lwsdk.LWSceneInfo()

# modify these paths if your Smedge sumbit is installed in a different location
if os.name == 'nt':
    smedgePath = '"D:\\Smedge3\\bin\\x64\\Debug\\Submit.exe"'
else:
    smedgePath = '/Applications/Smedge.app/Contents/MacOS/Submit'

cPath = ''
# set this to the filepath location to plugin config file.
# cPath = '"C:\\LightWave_Custom\\Ext\\2015.3"'

sj  = smedgePath
sj += ' Script'
sj += ' -MasterPort 8888'
sj += ' -Type LightWave'
sj += ' -Scene ' + lwSI.filename
sj += ' -Range ' + str( lwSI.frameStart ) + '-' + str( lwSI.frameEnd )
sj += ' -Name ' + lwSI.name
sj += ' -ContentDir ' + lwsdk.LWDirInfoFunc('Content')
sj += ' -ConfigFile ' + cPath

#  Time to do it!
try:
    subprocess.call( sj )
except:
    print lwSI.name + ' failed to submit to Smedge.'
else:
    print 'Submitted to Smedge!'
