diff --git a/sde_sync.py b/sde_sync.py index 90089e4..fca4929 100644 --- a/sde_sync.py +++ b/sde_sync.py @@ -452,7 +452,7 @@ class SdeSynchronous: def fc2fc(self, fc_name, out, fc_cur, expression, fc_type): """启动python子进程输出feature或者table到gdb""" python_path = str(self.config.python_path() + u' ').encode('gb2312') - script = str(u'sde_fc2fc.py ').encode('gb2312') + script = str(self.config.pathname + '\\sde_fc2fc.py ') src_sde = str(self.src_sde + ' ') type_cmd = str(fc_type + u' ').encode('gb2312') fc_name_cmd = str(fc_name + u' ').encode('gb2312') diff --git a/test_arcpy.py b/test/test_arcpy.py similarity index 100% rename from test_arcpy.py rename to test/test_arcpy.py diff --git a/test_functions.py b/test/test_functions.py similarity index 78% rename from test_functions.py rename to test/test_functions.py index 3ca5973..76fe91c 100644 --- a/test_functions.py +++ b/test/test_functions.py @@ -1,12 +1,17 @@ # coding=utf-8 import unittest +from imp import reload from functions import * +reload(sys) +sys.setdefaultencoding('utf8') +parent_path = os.path.abspath(os.path.dirname(os.getcwd())) + class TestFunctions(unittest.TestCase): def test_run_command(self): python_path = str(u'C:/Python27/ArcGIS10.2/python.exe ').encode('gb2312') - script = str(u'sde_fc2fc.py ').encode('gb2312') + script = str(parent_path + '\\sde_fc2fc.py ') type_cmd = str(u'feature ').encode('gb2312') fc_name_cmd = str(u'Building_A ').encode('gb2312') out_cmd = str(u'Building_A ').encode('gb2312') diff --git a/test_sde_sync.py b/test/test_sde_sync.py similarity index 95% rename from test_sde_sync.py rename to test/test_sde_sync.py index ac18d1b..2a8473e 100644 --- a/test_sde_sync.py +++ b/test/test_sde_sync.py @@ -1,18 +1,22 @@ # coding=utf-8 import unittest import inspect +from imp import reload + import arcpy from functions import * from sys_config import SysConfig from logger import Logger from sde_sync import SdeSynchronous +reload(sys) +sys.setdefaultencoding('utf8') + class TestSdeSynchronous(unittest.TestCase): def setUp(self): - # 获取当前路径 - caller_file = inspect.getfile(inspect.currentframe()) - work_pathname = os.path.abspath(os.path.dirname(caller_file)) + # 获取当前路径的父级路径 + work_pathname = os.path.abspath(os.path.dirname(os.getcwd())) # 同步开始时间 curr_sync_date = time.strftime("%Y-%m-%d", time.localtime()) curr_sync_time = time.strftime("%H-%M-%S", time.localtime()) @@ -27,7 +31,7 @@ class TestSdeSynchronous(unittest.TestCase): logger.log("==SdeSynchronous Started==") logger.log("Process begin at " + str(curr_sync_date) + " " + str(curr_sync_time) + ".") self.sde_db_sync = SdeSynchronous(config, logger) - self.sde_db_sync.src_sde = self.sde_db_sync.get_connection(str(u"源库SDE连接").encode('gb2312')) + self.sde_db_sync.src_sde = self.sde_db_sync.get_connection(str(u"源库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.edit = self.sde_db_sync.start_edit() diff --git a/test_sys_config.py b/test/test_sys_config.py similarity index 100% rename from test_sys_config.py rename to test/test_sys_config.py