We are using a bare bones ArcPy Script from the ESRI site to publish Map Services from ArcGIS Pro projects. When publishing, the default Time Zone is none but we want it changed to Pacific Time with values adjusted for daylight savings. Is there a way to do this when using arcpy when publishing?
<SPAN class="keyword token">for</SPAN> m <SPAN class="keyword token">in</SPAN> aprx<SPAN class="punctuation token">.</SPAN>listMaps<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">if</SPAN> mapNames <SPAN class="operator token">==</SPAN> <SPAN class="string token">"ALL"</SPAN> <SPAN class="operator token">or</SPAN> mapNames <SPAN class="operator token">==</SPAN> m<SPAN class="punctuation token">.</SPAN>name<SPAN class="punctuation token">:</SPAN>
AddMsgAndPrint<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Map: "</SPAN> <SPAN class="operator token">+</SPAN> m<SPAN class="punctuation token">.</SPAN>name<SPAN class="punctuation token">)</SPAN>
serviceName <SPAN class="operator token">=</SPAN> m<SPAN class="punctuation token">.</SPAN>name
SDPath <SPAN class="operator token">=</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>join<SPAN class="punctuation token">(</SPAN>tempPath<SPAN class="punctuation token">,</SPAN> serviceName <SPAN class="operator token">+</SPAN> <SPAN class="string token">".sd"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Create MapServiceDraft and set service properties</SPAN>
sddraft <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>sharing<SPAN class="punctuation token">.</SPAN>CreateSharingDraft<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'STANDALONE_SERVER'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'MAP_SERVICE'</SPAN><SPAN class="punctuation token">,</SPAN> serviceName<SPAN class="punctuation token">,</SPAN> m<SPAN class="punctuation token">)</SPAN>
sddraft<SPAN class="punctuation token">.</SPAN>targetServer <SPAN class="operator token">=</SPAN> server_con
sddraft<SPAN class="punctuation token">.</SPAN>serverFolder <SPAN class="operator token">=</SPAN> serverFolder
<SPAN class="comment token"># copyDataToServer = False will reference data from registered data sources with the targetServer</SPAN>
sddraft<SPAN class="punctuation token">.</SPAN>copyDataToServer <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">False</SPAN>
sddraft<SPAN class="punctuation token">.</SPAN>exportToSDDraft<SPAN class="punctuation token">(</SPAN>SDdraftPath<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Read the contents of the original SDDraft into an xml parser</SPAN>
doc <SPAN class="operator token">=</SPAN> DOM<SPAN class="punctuation token">.</SPAN>parse<SPAN class="punctuation token">(</SPAN>SDdraftPath<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># The follow code piece modifies the SDDraft from a new MapService with caching capabilities</SPAN>
<SPAN class="comment token"># to a FeatureService with Map, Create and Query capabilities.</SPAN>
typeNames <SPAN class="operator token">=</SPAN> doc<SPAN class="punctuation token">.</SPAN>getElementsByTagName<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'TypeName'</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> typeName <SPAN class="keyword token">in</SPAN> typeNames<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">if</SPAN> typeName<SPAN class="punctuation token">.</SPAN>firstChild<SPAN class="punctuation token">.</SPAN>data <SPAN class="operator token">==</SPAN> <SPAN class="string token">"FeatureServer"</SPAN><SPAN class="punctuation token">:</SPAN>
extention <SPAN class="operator token">=</SPAN> typeName<SPAN class="punctuation token">.</SPAN>parentNode
<SPAN class="keyword token">for</SPAN> extElement <SPAN class="keyword token">in</SPAN> extention<SPAN class="punctuation token">.</SPAN>childNodes<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">if</SPAN> extElement<SPAN class="punctuation token">.</SPAN>tagName <SPAN class="operator token">==</SPAN> <SPAN class="string token">'Enabled'</SPAN><SPAN class="punctuation token">:</SPAN>
extElement<SPAN class="punctuation token">.</SPAN>firstChild<SPAN class="punctuation token">.</SPAN>data <SPAN class="operator token">=</SPAN> <SPAN class="string token">'false'</SPAN>
<SPAN class="comment token"># Turn off caching</SPAN>
configProps <SPAN class="operator token">=</SPAN> doc<SPAN class="punctuation token">.</SPAN>getElementsByTagName<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'ConfigurationProperties'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
propArray <SPAN class="operator token">=</SPAN> configProps<SPAN class="punctuation token">.</SPAN>firstChild
propSets <SPAN class="operator token">=</SPAN> propArray<SPAN class="punctuation token">.</SPAN>childNodes
<SPAN class="keyword token">for</SPAN> propSet <SPAN class="keyword token">in</SPAN> propSets<SPAN class="punctuation token">:</SPAN>
keyValues <SPAN class="operator token">=</SPAN> propSet<SPAN class="punctuation token">.</SPAN>childNodes
<SPAN class="keyword token">for</SPAN> keyValue <SPAN class="keyword token">in</SPAN> keyValues<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">if</SPAN> keyValue<SPAN class="punctuation token">.</SPAN>tagName <SPAN class="operator token">==</SPAN> <SPAN class="string token">'Key'</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">if</SPAN> keyValue<SPAN class="punctuation token">.</SPAN>firstChild<SPAN class="punctuation token">.</SPAN>data <SPAN class="operator token">==</SPAN> <SPAN class="string token">"isCached"</SPAN><SPAN class="punctuation token">:</SPAN>
keyValue<SPAN class="punctuation token">.</SPAN>nextSibling<SPAN class="punctuation token">.</SPAN>firstChild<SPAN class="punctuation token">.</SPAN>data <SPAN class="operator token">=</SPAN> <SPAN class="string token">"false"</SPAN>
<SPAN class="comment token"># Write the new draft to disk</SPAN>
f <SPAN class="operator token">=</SPAN> open<SPAN class="punctuation token">(</SPAN>newSDdraftPath<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'w'</SPAN><SPAN class="punctuation token">)</SPAN>
doc<SPAN class="punctuation token">.</SPAN>writexml<SPAN class="punctuation token">(</SPAN>f<SPAN class="punctuation token">)</SPAN>
f<SPAN class="punctuation token">.</SPAN>close<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Stage the service</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>StageService_server<SPAN class="punctuation token">(</SPAN>newSDdraftPath<SPAN class="punctuation token">,</SPAN> SDPath<SPAN class="punctuation token">)</SPAN>
AddMsgAndPrint<SPAN class="punctuation token">(</SPAN><SPAN class="string token">" Staged service"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Upload the service</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>UploadServiceDefinition_server<SPAN class="punctuation token">(</SPAN>SDPath<SPAN class="punctuation token">,</SPAN> server_con<SPAN class="punctuation token">)</SPAN>
AddMsgAndPrint<SPAN class="punctuation token">(</SPAN><SPAN class="string token">" Uploaded service"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Delete drafts</SPAN>
Cleanup<SPAN class="punctuation token">(</SPAN>SDdraftPath<SPAN class="punctuation token">)</SPAN>
Cleanup<SPAN class="punctuation token">(</SPAN>newSDdraftPath<SPAN class="punctuation token">)</SPAN>
Cleanup<SPAN class="punctuation token">(</SPAN>SDPath<SPAN class="punctuation token">)</SPAN>
AddMsgAndPrint<SPAN class="punctuation token">(</SPAN><SPAN class="string token">" Removed temp files"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>