0
try: # Catch exceptions with try/except
    p4.connect() # Connect to the Perforce Server
    p4.run_login()

    client = p4.fetch_client()
    client['View'] = ['//TestPublic/Extern/firanl/... //mitica/TestPublic/Extern/firanl/...']  # workspace mapping
    p4.save_client(client)
#    p4.run_sync()   # this command stops the execution of other commands after this

    result = p4.run("fstat", perforce_path)[0]
    file1 = result['clientFile']

    change = p4.fetch_change()
    change._files = [file1]     #associate file to changelist
    change._description = 'aaaaaa'
    p4.run_submit(change)



    p4.disconnect() # Disconnect from the Server
except P4Exception:
    for e in p4.errors: # Display errors
        print e
#

When I run the code, will give me this error: "Error in change specification. Can't include file(s) not already opened. Open new files with p4 add, p4 edit, etc."

I tried to open the file with p4.run("edit", file1), but the program does nothing and doesn't run the next commands after this. How do I open the file and what are the python working commands for p4 add and p4 edit?

sferencik
  • 3,144
  • 1
  • 24
  • 36
  • 1
    Running "p4 edit" is the right thing to do. Time to debug: 1) Print the value of "file1" to make sure it's something reasonable. 2) Try running "p4 edit (file1)" from the command line. – Samwise Nov 15 '16 at 08:42

1 Answers1

1

Focus on your run_sync command. My guess is that it's not using the client you've just set up.

To verify what is getting used, run run_set and print its results.

To make sure you're using your client, first give it a name (using client['Name'] = 'MyClient') before saving it and then tell your P4Python to use it (p4.client = 'MyClient').

Then run your sync.

sferencik
  • 3,144
  • 1
  • 24
  • 36