print "Signing in to Portal" arcpy.SignInToPortal_server("login", "password", "http://www.arcgis.com/") # Process: Stage Service arcpy.StageService_server("file.sddraft", "file.sd") # Process: Upload Service Definition arcpy.UploadServiceDefinition_server("file.sd", "My Hosted Services", "ServiceName", "", "FROM_SERVICE_DEFINITION", "", "STARTED", "USE_DEFINITION", "NO_SHARE_ONLINE", "PRIVATE", "NO_SHARE_ORGANIZATION", "")
If you ended up here, you should check out this blog post if you are using ArcGIS 10.2 or greater. The moral of the story is that the SignInToPortal tool can no longer be used to login to ArcGIS Online from a stand alone Python script. If you have ArcMap or ArcCatalog open when you run the script, it works. Otherwise, you get the error that My Hosted Services does not exist or is not supported.
Instead, to make the script completely standalone, you have to use the ArcGIS REST API to update the feature service. They have a script with a configuration file that organizes the process for you.