default_test.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package test
  2. import (
  3. "ColdVerify_server/lib"
  4. "ColdVerify_server/logs"
  5. "fmt"
  6. "os/exec"
  7. "testing"
  8. "time"
  9. )
  10. func TestBeego(t *testing.T) {
  11. formatTimeStr := "2022-05-25 18:58"
  12. formatTime, err := time.Parse("2006-01-02 15:04", formatTimeStr)
  13. if err != nil {
  14. logs.Error(lib.FuncName(), err)
  15. }
  16. logs.Println("formatTime", formatTime) //打印结果:2017-04-11 13:33:37 +0000 UTC
  17. //// Read from docx file
  18. //r, err := docx.ReadDocxFile("./template.docx")
  19. //// Or read from memory
  20. //// r, err := docx.ReadDocxFromMemory(data io.ReaderAt, size int64)
  21. //
  22. //// Or read from a filesystem object:
  23. //// r, err := docx.ReadDocxFromFS(file string, fs fs.FS)
  24. //
  25. //if err != nil {
  26. // panic(err)
  27. //}
  28. //docx1 := r.Editable()
  29. //// Replace like https://golang.org/pkg/strings/#Replace
  30. //docx1.Replace("old_1_1", "new_1_1", -1)
  31. //docx1.Replace("old_1_2", "new_1_2", -1)
  32. ////docx1.ReplaceLink("http://example.com/", "https://github.com/nguyenthenguyen/docx", 1)
  33. ////docx1.ReplaceHeader("out with the old", "in with the new")
  34. ////docx1.ReplaceFooter("Change This Footer", "new footer")
  35. //docx1.WriteToFile("./new_result_1.docx")
  36. //
  37. //docx2 := r.Editable()
  38. //docx2.Replace("old_2_1", "new_2_1", -1)
  39. //docx2.Replace("old_2_2", "new_2_2", -1)
  40. //docx2.WriteToFile("./new_result_2.docx")
  41. //// Or write to ioWriter
  42. //// docx2.Write(ioWriter io.Writer)
  43. //docx3 := r.Editable()
  44. ////Currently only swaps apples for apples i.e. png to png, and not png to jpeg etc.
  45. ////d.ReplaceImage("word/media/image1.png", "./new.png")
  46. //docx3.WriteToFile("./new_result_3.docx")
  47. }
  48. func TestR(t *testing.T) {
  49. // 设置要执行的Python脚本和参数
  50. scriptPath := "../script"
  51. arg1 := "/Users/zoie/work/study/python/project/python2wordpdf_process-master/input.pdf"
  52. arg2 := "../ofile/watermarked.pdf"
  53. arg3 := "../script/watermark.pdf"
  54. // 执行Python脚本
  55. cmd := exec.Command("python", "add_watermark.py", arg1, arg2, arg3)
  56. cmd.Dir = scriptPath
  57. // 获取命令输出
  58. output, err := cmd.CombinedOutput()
  59. if err != nil {
  60. fmt.Println("Error:", err)
  61. //return
  62. }
  63. // 打印Python脚本的输出
  64. fmt.Println(string(output))
  65. }