Skip to content

Commit

Permalink
Merge pull request #7 from nrg12/master
Browse files Browse the repository at this point in the history
Cross platform compatibility
  • Loading branch information
andreiamatuni authored Feb 10, 2017
2 parents 8209833 + d27fd11 commit 5e6d6e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
5 changes: 2 additions & 3 deletions crawl_subject_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ def audio_wav_window(self):
def crawl_files(self, file_or_dirname):
self.start_button.config(state="disable")
self.tups=[]
print(self.chosen_subjects)
if self.recurse_or_scan.get():
if not file_or_dirname.endswith('.csv'):
tkMessageBox.showinfo("Error", "You must provide a csv file to scan or uncheck the top box.")
Expand Down Expand Up @@ -473,8 +472,8 @@ def copy_files(self, lst):
else:
for tup in lst:
filepath = tup[0]
localdir = os.path.dirname(filepath)
savepath = self.output_dir+localdir
drive, localdir = os.path.splitdrive(filepath)
savepath = os.path.join(self.output_dir,os.path.normpath(os.path.dirname(localdir)).lstrip(r"\\").lstrip("/"))
try:
with open(savepath) as f: pass
except IOError as e:
Expand Down
13 changes: 8 additions & 5 deletions mirror_script/mirror_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import Tkinter as tk # for python2
import tkFileDialog as tkfiledialog
import tkMessageBox
from Tkinter import ttk
import ttk
except ImportError:
import tkinter as tk # for python3
import tkinter.filedialog as tkfiledialog
Expand Down Expand Up @@ -117,7 +117,7 @@ def mirror_files(self, lst):
def mirror_files_to_csv(self, lst):
self.getSavePath()
x = self.save_filename
if not re.match("(.csv)$", self.save_filename):
if not x.endswith('.csv'):
x+=".csv"
with open(self.output_dir+'/'+x, 'a') as f:
writer = csv.writer(f)
Expand All @@ -130,16 +130,19 @@ def mirror_files_recursive(self, lst):
for tup in lst:
filepath = tup[0]
base_name = os.path.basename(filepath)
localdir = os.path.dirname(filepath)
savepath = os.path.join(self.output_dir,localdir[1:])
drive, localdir = os.path.splitdrive(filepath)
savepath = os.path.join(self.output_dir,os.path.normpath(os.path.dirname(localdir)).lstrip(r"\\").lstrip("/"))
try:
with open(savepath): pass
except IOError:
if not os.path.exists(savepath):
os.makedirs(savepath)
pathBefore = os.getcwd()
os.chdir(savepath)
subprocess.call(['touch', base_name])
try:
subprocess.call(['touch', base_name])
except WindowsError:
open(base_name,'a').close()
os.chdir(pathBefore)
tkMessageBox.showinfo("Completed", "Directory successfully mirrored!")

Expand Down

0 comments on commit 5e6d6e3

Please sign in to comment.