Exemplo n.º 1
0
def pmOpenFromServer():
   print 'Opening scene with server paths...'
   pm = PathMap( UnixSeparators = True, Verbose = True)

   # Get server scene name:
   scenename_server = nuke.getFilename('Select a scene with server paths','*.nk')
   if scenename_server is None: return

   # Get client scene name
   scenename_client = scenename_server
   clientname = CLIENT_PATHS_SUFFIX
   clientname += '-' + socket.gethostname()
   if scenename_client.find( SERVER_PATHS_SUFFIX) != -1:
      scenename_client = scenename_client.replace( SERVER_PATHS_SUFFIX, clientname)
   else:
      scenename_client += '.' + clientname + '.nk'

   # Map paths from server to client:
   error_msg = ''
   if pm.initialized:
      pm.toClientFile( scenename_server, scenename_client, SearchStrings, Verbose = True)
   else:
      print 'No paths map preset. Just copying scene to:'
      print scenename_client
      try:
         shutil.copy( scenename_server, scenename_client)
      except:
         error_msg = str(sys.exc_info()[1])
         print 'File copied with error:'
         print error_msg
         error_msg = '\n' + error_msg

   # Check if new scene exists:
   if not os.path.isfile(scenename_client):
      nuke.message('Client scene was not created.' + error_msg)
      return

   # Open client scene:
   nuke.scriptOpen( scenename_client)
Exemplo n.º 2
0
def pmSaveToServer():
   print 'Saving scene to server paths...'
   pm = PathMap( UnixSeparators = True, Verbose = True)
   nuke.scriptSave()

   # Get server scene name:
   scenename = nuke.root().name()
   scenename_server = scenename + '.' + SERVER_PATHS_SUFFIX + '.nk'

   # Map paths from client to server:
   error_msg = ''
   if pm.initialized:
      pm.toServerFile( scenename, scenename_server, SearchStrings, Verbose = True)
   else:
      print 'No paths map preset. Just copying scene to:'
      print scenename_server
      try:
         shutil.copy( scenename, scenename_server)
      except:
         error_msg = str(sys.exc_info()[1])
         print 'File copied with error:'
         print error_msg

   if error_msg != '': nuke.message('Server scene copy error:\n' + error_msg)
Exemplo n.º 3
0
if sys.argv[ArgNum] == 'unix':
	UnixSeparators = True
	ArgNum = 2

path = sys.argv[ArgNum]

if os.path.isfile(path):
	strings = []
	for i in range(ArgNum + 1, len(sys.argv)):
		strings.append(sys.argv[i])

	if len(strings):
		print('Search for strings:')
		print(strings)

	pm = PathMap(UnixSeparators, Verbose=True)
	path_server = path + '_server'
	path_client = path + '_client'
	print('To server filename = "%s"' % path_server)
	pm.toServerFile(path, path_server, strings, Verbose=False)
	print('To client filename = "%s"' % path_client)
	pm.toClientFile(path_server, path_client, strings, Verbose=False)
else:
	path = ''
	for arg in range(ArgNum, len(sys.argv)):
		if arg != ArgNum:
			path += ' '
		path += sys.argv[arg]
	pm = PathMap(UnixSeparators, Verbose=True)
	print('                  1         2         3         4         5         6         7')
	print('        012345678901234567890123456789012345678901234567890123456789012345678901234567890')
Exemplo n.º 4
0
if sys.argv[ArgNum] == 'unix':
    UnixSeparators = True
    ArgNum = 2

path = sys.argv[ArgNum]

if os.path.isfile(path):
    strings = []
    for i in range(ArgNum + 1, len(sys.argv)):
        strings.append(sys.argv[i])

    if len(strings):
        print('Search for strings:')
        print(strings)

    pm = PathMap(UnixSeparators, Verbose=True)
    path_server = path + '_server'
    path_client = path + '_client'
    print('To server filename = "%s"' % path_server)
    pm.toServerFile(path, path_server, strings, Verbose=False)
    print('To client filename = "%s"' % path_client)
    pm.toClientFile(path_server, path_client, strings, Verbose=False)
else:
    path = ''
    for arg in range(ArgNum, len(sys.argv)):
        if arg != ArgNum:
            path += ' '
        path += sys.argv[arg]
    pm = PathMap(UnixSeparators, Verbose=True)
    print(
        '                  1         2         3         4         5         6         7'