diff --git a/.gitignore b/.gitignore
index 763cd41..3f59fb0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
/log/
/NEWGDB/
+/NEWMDO/
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
index 032f518..9ce9144 100644
--- a/.idea/encodings.xml
+++ b/.idea/encodings.xml
@@ -6,5 +6,6 @@
+
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
deleted file mode 100644
index 65dfbcd..0000000
--- a/.vscode/settings.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "python.pythonPath": "c:\\Python27\\ArcGIS10.2\\python.exe"
-}
\ No newline at end of file
diff --git a/main.py b/main.py
index a2eaba0..3ad7a24 100644
--- a/main.py
+++ b/main.py
@@ -21,8 +21,10 @@ if __name__ == '__main__':
curr_sync_time = time.strftime("%H-%M-%S", time.localtime())
# 设置当前工作路径
config = SysConfig()
- config.pathname = work_pathname
+ config.pathname = work_pathname.decode('gb2312')
config.curr_sync_datetime = curr_sync_date + " " + curr_sync_time
+
+ print(work_pathname.decode('gb2312'))
# 日志记录
create_dir(work_pathname + "\\log")
config.logfile_name = work_pathname + "\\log\\" + config.curr_sync_datetime + "-SdeSynchronous.txt"
diff --git a/run.bat b/run.bat
new file mode 100644
index 0000000..bfc9d97
--- /dev/null
+++ b/run.bat
@@ -0,0 +1,4 @@
+@echo off
+cd /d %~dp0
+C:/Python27/ArcGIS10.2/python.exe main.py
+pause
\ No newline at end of file
diff --git a/sde_sync.py b/sde_sync.py
index fca4929..6fe28d9 100644
--- a/sde_sync.py
+++ b/sde_sync.py
@@ -28,12 +28,12 @@ class SdeSynchronous:
def run(self):
"""同步的主函数"""
# 1.连接SDE数据库
- self.src_sde = self.get_connection(str(u"源库SDE连接"))
+ self.src_sde = self.get_connection(str(u"源库SDE连接")).encode('gb2312')
if self.src_sde == "" or self.src_sde is None:
self.logger.error("src_sde Connection file not exist!")
else:
self.create_gdb_files()
- txt_path = self.out_gdb_path + "\\" + str(u"图层数量统计.txt").encode("gb2312")
+ txt_path = self.out_gdb_path + "\\" + u"图层数量统计.txt"
self.txt_ct_file = open(txt_path, "wb+", buffering=0)
# 开始编辑SDE
edit = self.start_edit()
@@ -90,7 +90,7 @@ class SdeSynchronous:
if bool_save:
# 开始输出mdo
- # self.copy_to_mdo(str(self.out_gdb_path).encode('gbk'))
+ # self.copy_to_mdo(self.out_gdb_path)
# 转换到旧标准的gdb
self.trans_to_old()
# 输出保密的gdb
@@ -121,15 +121,15 @@ class SdeSynchronous:
def get_connection(self, sub_path):
"""获取SDE连接"""
- for fileName in os.listdir(self.config.pathname + "\\" + sub_path.encode("gb2312")):
+ for fileName in os.listdir(self.config.pathname.encode('gb2312') + "\\" + sub_path.encode("gb2312")):
if fnmatch.fnmatch(fileName, '*.sde'):
- return self.config.pathname + "\\" + sub_path.encode('gb2312') + "\\" + fileName
+ return self.config.pathname + "\\" + sub_path + "\\" + fileName
return ""
def start_edit(self):
"""开始编辑"""
arcpy.env.workspace = self.src_sde
- print(self.src_sde.decode("gb2312"))
+ print(self.src_sde)
edit = arcpy.da.Editor(self.src_sde)
edit.startEditing(False, False)
edit.startOperation()
diff --git a/test/test.py b/test/test.py
new file mode 100644
index 0000000..d43d854
--- /dev/null
+++ b/test/test.py
@@ -0,0 +1,6 @@
+import unittest
+
+if __name__ == "__main__":
+ test_suite = unittest.TestLoader().discover('.')
+ runner = unittest.TextTestRunner(verbosity=2)
+ runner.run(test_suite)
diff --git a/test/test_sde_sync.py b/test/test_sde_sync.py
index 2a8473e..da3ec96 100644
--- a/test/test_sde_sync.py
+++ b/test/test_sde_sync.py
@@ -35,6 +35,7 @@ class TestSdeSynchronous(unittest.TestCase):
arcpy.env.workspace = self.sde_db_sync.src_sde
self.sde_db_sync.config.last_sync_datetime = self.sde_db_sync.get_last_sync_datetime()
self.edit = self.sde_db_sync.start_edit()
+ self.sde_db_sync.create_gdb_files()
def tearDown(self):
self.sde_db_sync.stop_edit(self.edit, False)
@@ -53,7 +54,6 @@ class TestSdeSynchronous(unittest.TestCase):
print(self.sde_db_sync.get_projects_info())
def test_create_gdb_files(self):
- self.sde_db_sync.create_gdb_files()
self.assertTrue(os.path.exists(self.sde_db_sync.out_gdb_path))
self.assertTrue(os.path.exists(self.sde_db_sync.out_gdb_path + "\\" + self.sde_db_sync.out_gdb_files["Add"]))
self.assertTrue(os.path.exists(self.sde_db_sync.out_gdb_path + "\\" + self.sde_db_sync.out_gdb_files["Edit"]))
@@ -95,6 +95,9 @@ class TestSdeSynchronous(unittest.TestCase):
self.sde_db_sync.create_gdb_files()
self.sde_db_sync.featureclass_to_featureclass("Building_A", self.sde_db_sync.out_gdb_path + "\\" + self.sde_db_sync.out_gdb_files["Add"], "Building_A", "ObjectID>0")
+ def test_copy_to_mdo(self):
+ self.sde_db_sync.copy_to_mdo(self.sde_db_sync.out_gdb_path)
+
if __name__ == '__main__':
unittest.main()