IoTtalk / iottalk-py

IoTtalk v2 Python SDK
MIT License
0 stars 6 forks source link

Python2 support #24

Closed iblislin closed 4 years ago

iblislin commented 4 years ago
Ming-Hsun commented 4 years ago

了解

Iblis Lin notifications@github.com於 2020年1月18日 週六,下午6:00寫道:

@iblis17 commented on this pull request.

In tests/test_dai.py https://github.com/IoTtalk/iottalk-py/pull/24#discussion_r368218680:

+''')

  • fp2.close()

  • fp_dir2_name = os.path.basename(fp_dir2)

  • c = os.path.basename(fp2.name)

  • c = os.path.splitext(c)[0]

  • c = os.path.join(fp_dir2_name, c)

  • d = os.path.basename(fp2.name)

  • d = os.path.join(fp_dir2_name, d)

  • yield [a, b, c, d]

  • os.unlink(fp1.name)

  • shutil.rmtree(fp_dir2)

  • shutil.rmtree(fp_dir1)

+def test_load_module1(fname):

底下的所有 function 是重複的,改用 parametrize 吧。 寫成單一一個 function

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/IoTtalk/iottalk-py/pull/24?email_source=notifications&email_token=ANXR5DIWEE4S5P6IUYYVWRTQ6LHMBA5CNFSM4KBRRZY2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCSHU5HA#pullrequestreview-344936092, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANXR5DKPEHNW7OKFO5VWCOLQ6LHMBANCNFSM4KBRRZYQ .

iblislin commented 4 years ago

@Ming-Hsun coding style 還需要改一下

Ming-Hsun commented 4 years ago

好的 了解

Iblis Lin notifications@github.com於 2020年1月21日 週二,下午6:19寫道:

@Ming-Hsun https://github.com/Ming-Hsun coding style 還需要改一下

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/IoTtalk/iottalk-py/pull/24?email_source=notifications&email_token=ANXR5DPTHJSR2I5NQVOWDFLQ63D3FA5CNFSM4KBRRZY2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJPG43Q#issuecomment-576613998, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANXR5DOX4UXCV2MKE6VTMT3Q63D3FANCNFSM4KBRRZYQ .

Ming-Hsun commented 4 years ago

我用 paramertrize 如果臨時資料夾被刪除,load_module()會失敗、找不到該檔案,所以我現在先把刪除資料夾移除。

Ming-Hsun commented 4 years ago

如果不指定這個資料夾的話,mkdtemp 預設在 /tmp 下,我是不是就不能用相對位置了,因為我的 test_dai.py 檔案不在 /tmp 底下。

Iblis Lin notifications@github.com 於 2020年1月30日 週四 下午10:09寫道:

@iblis17 commented on this pull request.

In tests/test_dai.py https://github.com/IoTtalk/iottalk-py/pull/24#discussion_r372968674:

  • fp1 = tempfile.NamedTemporaryFile(suffix='.py', dir=fp_dir1, delete=False)
  • fp1.write(b'''

+api_url = 'http://localhost:9992'

+device_module = 'Dummy_Device'

+idf_list = ['Dummy_Sensor']

+push_interval = 10

+interval = {

  • 'Dummy_Sensor': 1,

+}

+''')

  • fp1.close()

  • a = fp1.name

  • b = os.path.splitext(fp1.name)[0]

  • fp_dir2 = tempfile.mkdtemp(dir='/home/ken/iottalk-py/tests/')

這邊都 mkdtemp 希望不要指定 dir, 因爲我們我的機器這個資料夾不存在

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/IoTtalk/iottalk-py/pull/24?email_source=notifications&email_token=ANXR5DKQQ3DVHIUYE4W67FDRALNS3A5CNFSM4KBRRZY2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCTUYQCA#pullrequestreview-350849032, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANXR5DKNWZH7I26OC3TIT43RALNS3ANCNFSM4KBRRZYQ .

iblislin commented 4 years ago

如果不指定這個資料夾的話,mkdtemp 預設在 /tmp 下,我是不是就不能用相對位置了,因為我的 test_dai.py 檔案不在 /tmp 底下。

相對位置還是可以實作,操作上用 cd,把這種操作改成用 Python code 寫。

iblislin commented 4 years ago

基本上用 command line 能夠做到都事情, Python 都做的到,只是寫成 Python code

Ming-Hsun commented 4 years ago

好的 了解

iblislin commented 4 years ago

parameterized 的問題我改掉了

iblislin commented 4 years ago

接下來幫我寫個新的 function: test_load_module_nonexists input 是不存在的路徑,也是 4 種 input: 有 .py、沒 .py、相對/絕對路徑,預期 output 是要有 error

iblislin commented 4 years ago

然後幫我看一下 coverage 如何?

Ming-Hsun commented 4 years ago

好的 我下禮拜ㄧ做

Iblis Lin notifications@github.com於 2020年1月31日 週五,下午6:04寫道:

然後幫我看一下 coverage 如何?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/IoTtalk/iottalk-py/pull/24?email_source=notifications&email_token=ANXR5DK4NBUJPCTXEQZ2IDLRAPZUXA5CNFSM4KBRRZY2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKOE4LY#issuecomment-580668975, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANXR5DOTRRIS7HX4QKH6DGDRAPZUXANCNFSM4KBRRZYQ .