I have a basic python code that is intended to take the contents of a File GDB and ZIP them (not that actual .gdb itself though). When I test the code it says it's all good. When I run the code however, it goes straight to "Exit Code 0" and nothing happens. No new ZIP file, nothing. Any ideas where I'm going wrong?
<SPAN class="keyword token">import</SPAN> os
<SPAN class="keyword token">import</SPAN> shutil
<SPAN class="keyword token">import</SPAN> zipfile
<SPAN class="comment token"># Creates a zip file containing the input shapefile</SPAN>
<SPAN class="comment token"># inFileGDB: Full path to FileGDB folder to be zipped</SPAN>
<SPAN class="comment token"># Delete: Set to True to delete fileGDB files after zip</SPAN>
<SPAN class="comment token"># Creates a zip file containing the contents of a filegeodatabase</SPAN>
<SPAN class="keyword token">def</SPAN> <SPAN class="token function">Zipfgdb</SPAN><SPAN class="punctuation token">(</SPAN>inFileGDB <SPAN class="operator token">=</SPAN> r<SPAN class="string token">'\\my\data\pathway\MyData.gdb'</SPAN><SPAN class="punctuation token">,</SPAN> Delete <SPAN class="operator token">=</SPAN> <SPAN class="string token">'False'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN> inFileGDB <SPAN class="operator token">+</SPAN> <SPAN class="string token">" : Delete original files = "</SPAN> <SPAN class="operator token">+</SPAN> Delete
<SPAN class="comment token">#Directory of file geodatabase</SPAN>
inLocation <SPAN class="operator token">=</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>dirname <SPAN class="punctuation token">(</SPAN>inFileGDB<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"inLocation: "</SPAN> <SPAN class="operator token">+</SPAN> inLocation
<SPAN class="comment token">#Base name of shapefile</SPAN>
inName <SPAN class="operator token">=</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>basename <SPAN class="punctuation token">(</SPAN>os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>splitext<SPAN class="punctuation token">(</SPAN>inFileGDB<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"inName: "</SPAN> <SPAN class="operator token">+</SPAN> inName
<SPAN class="comment token">#Create the zipfile name </SPAN>
zipfl <SPAN class="operator token">=</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>join <SPAN class="punctuation token">(</SPAN>inLocation<SPAN class="punctuation token">,</SPAN> inName <SPAN class="operator token">+</SPAN> <SPAN class="string token">".zip"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"New ZIP file: "</SPAN> <SPAN class="operator token">+</SPAN> zipfl
<SPAN class="comment token">#Create zipfile object</SPAN>
ZIP <SPAN class="operator token">=</SPAN> zipfile<SPAN class="punctuation token">.</SPAN>ZipFile <SPAN class="punctuation token">(</SPAN>zipfl<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"w"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"ZIP file created"</SPAN>
<SPAN class="comment token">#Iterate files in shapefile directory</SPAN>
<SPAN class="keyword token">for</SPAN> fl <SPAN class="keyword token">in</SPAN> os<SPAN class="punctuation token">.</SPAN>listdir <SPAN class="punctuation token">(</SPAN>inFileGDB<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token">#Get full path of file</SPAN>
inFile <SPAN class="operator token">=</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>join <SPAN class="punctuation token">(</SPAN>inFileGDB<SPAN class="punctuation token">,</SPAN> fl<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#Add file to zipfile. exclude any lock files</SPAN>
<SPAN class="keyword token">if</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>splitext<SPAN class="punctuation token">(</SPAN>fl<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token"><></SPAN> <SPAN class="string token">'lock'</SPAN><SPAN class="punctuation token">:</SPAN>
ZIP<SPAN class="punctuation token">.</SPAN>write<SPAN class="punctuation token">(</SPAN>inFile<SPAN class="punctuation token">,</SPAN>fl<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"files added to ZIP file"</SPAN>
<SPAN class="comment token">#Delete filegeodatabase if indicated</SPAN>
<SPAN class="keyword token">if</SPAN> Delete <SPAN class="operator token">==</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">:</SPAN>
shutil<SPAN class="punctuation token">.</SPAN>rmtree<SPAN class="punctuation token">(</SPAN>inFileGDB<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"Original file deleted"</SPAN>
<SPAN class="comment token">#Close zipfile object</SPAN>
ZIP<SPAN class="punctuation token">.</SPAN>close<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#Return zipfile full path</SPAN>
<SPAN class="keyword token">return</SPAN> zipfl
<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>