I would like to compile and distribute (on .net) some python programs that work well with IronPython, but I am new to .net and am getting errors related to particular python modules. There is a utility for compiling to low level .net and it works well, but I get errors when dealing with common libraries; code that runs in the interpreter does not necessarily compile. For example, the below takes advantage of the basic modules shutil
, getpass
, and os
. getpass.getuser()
returns a username as a string. shutil
provides, among other things, a copy function (although that one I can rewrite in pure python and get to compile), and os
is used here for getting folder info, making dirs and unlinking files. How might I adapt stuff along the following lines, in whole or any part, to use only libraries native to .net? If anyone has used IronPython as a bridge from python to learning .net any related tips are appreciated.
import shutil
import os
import getpass
uname = getpass.getuser()
folders = ["/users/"+uname+"/location", "/users/"+uname+"/other_location"]
for folder in folders:
for root, dir, files in os.walk(folder):
for file in files:
file_name = os.path.join(root, file)
time_stamp = os.stat(file_name).st_mtime
time_dict[time_stamp] = file_name
working_list.append(time_stamp)
def sync_up():
for item in working_list:
if item not in update_list:
os.remove(item)
else:
shutil.copy2(item, some_other_folder)
def cp_function(target=some_folder):
if os.path.exists(target):
sync_up()
else:
try:
os.mkdir(target)
sync_up()
except:
print """error connecting
"""