移动test文件到test目录
This commit is contained in:
parent
822e18e6a5
commit
35344439b6
|
@ -1,2 +1,3 @@
|
||||||
/log/
|
/log/
|
||||||
/NEWGDB/
|
/NEWGDB/
|
||||||
|
/NEWMDO/
|
||||||
|
|
|
@ -6,5 +6,6 @@
|
||||||
<file url="file://$PROJECT_DIR$/log/2023-05-27 15-11-29-Translate2Old.txt" charset="GBK" />
|
<file url="file://$PROJECT_DIR$/log/2023-05-27 15-11-29-Translate2Old.txt" charset="GBK" />
|
||||||
<file url="file://$PROJECT_DIR$/log/2023-05-27 15-20-40-Translate2Old.txt" charset="GBK" />
|
<file url="file://$PROJECT_DIR$/log/2023-05-27 15-20-40-Translate2Old.txt" charset="GBK" />
|
||||||
<file url="file://$PROJECT_DIR$/log/2023-05-27 15-32-50-SdeSynchronous.txt" charset="GBK" />
|
<file url="file://$PROJECT_DIR$/log/2023-05-27 15-32-50-SdeSynchronous.txt" charset="GBK" />
|
||||||
|
<file url="file://$PROJECT_DIR$/log/2023-05-29 17-11-32-SdeSynchronous.txt" charset="GBK" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"python.pythonPath": "c:\\Python27\\ArcGIS10.2\\python.exe"
|
|
||||||
}
|
|
4
main.py
4
main.py
|
@ -21,8 +21,10 @@ if __name__ == '__main__':
|
||||||
curr_sync_time = time.strftime("%H-%M-%S", time.localtime())
|
curr_sync_time = time.strftime("%H-%M-%S", time.localtime())
|
||||||
# 设置当前工作路径
|
# 设置当前工作路径
|
||||||
config = SysConfig()
|
config = SysConfig()
|
||||||
config.pathname = work_pathname
|
config.pathname = work_pathname.decode('gb2312')
|
||||||
config.curr_sync_datetime = curr_sync_date + " " + curr_sync_time
|
config.curr_sync_datetime = curr_sync_date + " " + curr_sync_time
|
||||||
|
|
||||||
|
print(work_pathname.decode('gb2312'))
|
||||||
# 日志记录
|
# 日志记录
|
||||||
create_dir(work_pathname + "\\log")
|
create_dir(work_pathname + "\\log")
|
||||||
config.logfile_name = work_pathname + "\\log\\" + config.curr_sync_datetime + "-SdeSynchronous.txt"
|
config.logfile_name = work_pathname + "\\log\\" + config.curr_sync_datetime + "-SdeSynchronous.txt"
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
@echo off
|
||||||
|
cd /d %~dp0
|
||||||
|
C:/Python27/ArcGIS10.2/python.exe main.py
|
||||||
|
pause
|
12
sde_sync.py
12
sde_sync.py
|
@ -28,12 +28,12 @@ class SdeSynchronous:
|
||||||
def run(self):
|
def run(self):
|
||||||
"""同步的主函数"""
|
"""同步的主函数"""
|
||||||
# 1.连接SDE数据库
|
# 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:
|
if self.src_sde == "" or self.src_sde is None:
|
||||||
self.logger.error("src_sde Connection file not exist!")
|
self.logger.error("src_sde Connection file not exist!")
|
||||||
else:
|
else:
|
||||||
self.create_gdb_files()
|
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)
|
self.txt_ct_file = open(txt_path, "wb+", buffering=0)
|
||||||
# 开始编辑SDE
|
# 开始编辑SDE
|
||||||
edit = self.start_edit()
|
edit = self.start_edit()
|
||||||
|
@ -90,7 +90,7 @@ class SdeSynchronous:
|
||||||
|
|
||||||
if bool_save:
|
if bool_save:
|
||||||
# 开始输出mdo
|
# 开始输出mdo
|
||||||
# self.copy_to_mdo(str(self.out_gdb_path).encode('gbk'))
|
# self.copy_to_mdo(self.out_gdb_path)
|
||||||
# 转换到旧标准的gdb
|
# 转换到旧标准的gdb
|
||||||
self.trans_to_old()
|
self.trans_to_old()
|
||||||
# 输出保密的gdb
|
# 输出保密的gdb
|
||||||
|
@ -121,15 +121,15 @@ class SdeSynchronous:
|
||||||
|
|
||||||
def get_connection(self, sub_path):
|
def get_connection(self, sub_path):
|
||||||
"""获取SDE连接"""
|
"""获取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'):
|
if fnmatch.fnmatch(fileName, '*.sde'):
|
||||||
return self.config.pathname + "\\" + sub_path.encode('gb2312') + "\\" + fileName
|
return self.config.pathname + "\\" + sub_path + "\\" + fileName
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def start_edit(self):
|
def start_edit(self):
|
||||||
"""开始编辑"""
|
"""开始编辑"""
|
||||||
arcpy.env.workspace = self.src_sde
|
arcpy.env.workspace = self.src_sde
|
||||||
print(self.src_sde.decode("gb2312"))
|
print(self.src_sde)
|
||||||
edit = arcpy.da.Editor(self.src_sde)
|
edit = arcpy.da.Editor(self.src_sde)
|
||||||
edit.startEditing(False, False)
|
edit.startEditing(False, False)
|
||||||
edit.startOperation()
|
edit.startOperation()
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
test_suite = unittest.TestLoader().discover('.')
|
||||||
|
runner = unittest.TextTestRunner(verbosity=2)
|
||||||
|
runner.run(test_suite)
|
|
@ -35,6 +35,7 @@ class TestSdeSynchronous(unittest.TestCase):
|
||||||
arcpy.env.workspace = self.sde_db_sync.src_sde
|
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.sde_db_sync.config.last_sync_datetime = self.sde_db_sync.get_last_sync_datetime()
|
||||||
self.edit = self.sde_db_sync.start_edit()
|
self.edit = self.sde_db_sync.start_edit()
|
||||||
|
self.sde_db_sync.create_gdb_files()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.sde_db_sync.stop_edit(self.edit, False)
|
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())
|
print(self.sde_db_sync.get_projects_info())
|
||||||
|
|
||||||
def test_create_gdb_files(self):
|
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.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["Add"]))
|
||||||
self.assertTrue(os.path.exists(self.sde_db_sync.out_gdb_path + "\\" + self.sde_db_sync.out_gdb_files["Edit"]))
|
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.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")
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue