build.p5ant.safety.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project basedir="../../." name="p5ant.safety"
  3. xmlns:p5ant="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache.public/ant/ant.xsd"
  4. >
  5. <description> safety functions to protect system failures etc </description>
  6. <include file="build.p5ant.safety.PRODUCT.xml" as="PRODUCT"/>
  7. <include file="../system_ui_info_speech/build.system_ui_info_speech.PRODUCT.xml" as="p5suis"/>
  8. <include file="../apple/build_apple.xml" as="p5apl" optional="yes"/>
  9. <!--<include file="build_ant.xml" optional="true" as="build_ant"/>-->
  10. <!--<import file="build_ant.xml" optional="yes" as="p5ant"/>-->
  11. <target name="open_file.input">
  12. <input addproperty="local.p5ant.safety.limit.file.size__x3A__open_file" message="local.p5ant.safety.limit.file.size__x3A__open_file" defaultvalue="${p5ant.safety.limit.file.size__x3A__open_file}"/>
  13. <input addproperty="local.p5ant.safety.limit.file.size__x3A__open_file.units" message="local.p5ant.safety.limit.file.size__x3A__open_file.units [M], [k], [G]" defaultvalue="${p5ant.safety.limit.file.size__x3A__open_file.units}" />
  14. <input addproperty="local.p5ant.safety.filename" message="local.p5ant.safety.filename" />
  15. <property name="local.p5apl.terminal-notifier.open" value="${local.p5ant.safety.filename}"/>
  16. </target>
  17. <target name="limit.file.size__x3A__open_file.if_not_exists.condition">
  18. <condition property="limit.file.size__x3A__open_file.if_not_exists">
  19. <available file="${local.p5ant.safety.filename}"/>
  20. </condition>
  21. </target>
  22. <target name="limit.file.size__x3A__open_file.if_not_exists" if="limit.file.size__x3A__open_file.if_not_exists">
  23. <property name="local.p5apl.terminal-notifier.message" value="Brak oczekiwanego pliku do otwarcia ${local.p5ant.safety.filename}"/>
  24. <property name="local.p5apl.terminal-notifier.title" value="p5ant.safety"/>
  25. <property name="local.p5apl.terminal-notifier.subtitle" value="file not exists "/>
  26. <property name="limit.file.size__x3A__open_file__x3A__deny_flag" value="denied by limit.file.size__x3A__open_file.if_not_exists ${local.p5apl.terminal-notifier.message}"/>
  27. <echo>#32 [ S A F E T Y ] [ F I L E N O T E X I S T S ]
  28. $limit.file.size__x3A__open_file.if_not_exists = ${limit.file.size__x3A__open_file.if_not_exists}
  29. $local.p5apl.terminal-notifier.message = ${local.p5apl.terminal-notifier.message}
  30. </echo>
  31. <ant antfile="${p5suis.build}" target="p5suis:say_to_queue.PL">
  32. <property name="p5suis:say_text" value="${local.p5apl.terminal-notifier.message}"/>
  33. </ant>
  34. </target>
  35. <target name="limit.file.size__x3A__open_file.if_exceeded" unless="limit.file.size__x3A__open_file.if_not_exists">
  36. <input addproperty="local.p5ant.safety.filename" message="local.p5ant.safety.filename type!"/>
  37. <input addproperty="local.p5ant.safety.limit.file.size__x3A__open_file.units" message="local.p5ant.safety.limit.file.size__x3A__open_file.units" defaultvalue="${p5ant.safety.limit.file.size__x3A__open_file.units}" />
  38. <input addproperty="local.p5ant.safety.limit.file.size__x3A__open_file" message="local.p5ant.safety.limit.file.size__x3A__open_file" defaultvalue="${p5ant.safety.limit.file.size__x3A__open_file}"/>
  39. <fileset id="limit.file.size__x3A__open_file.if_exceeded.fileset" file="${local.p5ant.safety.filename}">
  40. <size value="${local.p5ant.safety.limit.file.size__x3A__open_file}" units="${local.p5ant.safety.limit.file.size__x3A__open_file.units}" when="more"/>
  41. </fileset>
  42. <property name="limit.file.size__x3A__open_file.if_exceeded.fileset" refid="limit.file.size__x3A__open_file.if_exceeded.fileset"/>
  43. <length property="local.p5ant.safety.filename.length" file="${local.p5ant.safety.filename}" />
  44. <condition property="limit.file.size__x3A__open_file.if_exceeded" value="is exceeded file : ${limit.file.size__x3A__open_file.if_exceeded.fileset} ">
  45. <!--<istrue value="${local.p5ant.safety.filename.length}"/>-->
  46. <and>
  47. <contains string="${local.p5ant.safety.filename}" substring="${limit.file.size__x3A__open_file.if_exceeded.fileset}"/>
  48. <not>
  49. <equals arg1="${limit.file.size__x3A__open_file.if_exceeded.fileset}" arg2="" />
  50. </not>
  51. </and>
  52. <!--<isset property="limit.file.size__x3A__open_file.if_exceeded.fileset"/>-->
  53. </condition>
  54. <condition property="limit.file.size__x3A__open_file__x3A__deny_flag" value="is exceeded file : ${limit.file.size__x3A__open_file.if_exceeded.fileset}">
  55. <and>
  56. <contains string="${local.p5ant.safety.filename}" substring="${limit.file.size__x3A__open_file.if_exceeded.fileset}"/>
  57. <not>
  58. <equals arg1="${limit.file.size__x3A__open_file.if_exceeded.fileset}" arg2="" />
  59. </not>
  60. </and>
  61. </condition>
  62. <echo> #30 [? C O N D I T I O N ?] results:
  63. [ $limit.file.size__x3A__open_file.if_exceeded = ${limit.file.size__x3A__open_file.if_exceeded} ]
  64. [ $local.p5ant.safety.limit.file.size__x3A__open_file.units = ${local.p5ant.safety.limit.file.size__x3A__open_file.units} ]
  65. [ $limit.file.size__x3A__open_file.if_exceeded.fileset = ${limit.file.size__x3A__open_file.if_exceeded.fileset} ]
  66. [ $limit.file.size__x3A__open_file__x3A__deny_flag = ${limit.file.size__x3A__open_file__x3A__deny_flag} ]
  67. </echo>
  68. </target>
  69. <target name="limit.file.size__x3A__open_file.rename" if="limit.file.size__x3A__open_file.if_exceeded">
  70. <input addproperty="local.p5ant.safety.filename" message="local.p5ant.safety.filename type!"/>
  71. <property name="local.p5ant.safety.filename.rename" value="${local.p5ant.safety.filename}${p5ant.safety.limit.file.size.exceeded.suffix}"/>
  72. <property name="limit.file__x3A__open_file.if_exceeded" value="size exceeded"/>
  73. <echo>#34[ S A F E T Y R E N A M E ] = [!! F I L E T O O B I G = ${local.p5ant.safety.filename.length} !!!!] !!!!!!!!!!!!!!!!!!!!
  74. from $local.p5ant.safety.filename ${local.p5ant.safety.filename}
  75. to $local.p5ant.safety.filename.rename ${local.p5ant.safety.filename.rename}
  76. SET $limit.file__x3A__open_file.if_exceeded to ${limit.file__x3A__open_file.if_exceeded}
  77. </echo>
  78. <move file="${local.p5ant.safety.filename}" tofile="${local.p5ant.safety.filename.rename}" verbose="true"/>
  79. </target>
  80. <target name="limit.file.size__x3A__open_file.notify" if="limit.file.size__x3A__open_file.if_exceeded"> <!-- limit.file.size__x3A__open_file.if_exceeded -->
  81. <echo>#71 [ N O T I F Y ] $limit.file.size__x3A__open_file.if_exceeded = ${limit.file.size__x3A__open_file.if_exceeded} </echo>
  82. <property name="local.p5apl.terminal-notifier.message" value="safety limit wielkości pliku przekroczony w celu jego otwarcia dla pliku p5:file"/>
  83. <property name="local.p5apl.terminal-notifier.title" value="p5ant.safety"/>
  84. <property name="local.p5apl.terminal-notifier.subtitle" value="size limit exceeded"/>
  85. <ant antfile="${p5suis.build}" target="p5suis:say_to_queue.PL">
  86. <property name="p5suis:say_text" value="safety limit wielkości pliku przekroczony w celu jego otwarcia dla pliku p5:file ${local.p5ant.safety.filename} .
  87. Wielkość pliku to ${local.p5ant.safety.filename.length} .
  88. Następuje zmiana nazwy na p5:file ${local.p5ant.safety.filename.rename} .
  89. "/>
  90. </ant>
  91. </target>
  92. <target name="limit__x3A__open_file.sleep" if="limit.file__x3A__open_file.if_exceeded">
  93. <echo>#34 S A F E T Y S L E E P (TODO) by @if $limit.file__x3A__open_file.if_exceeded = ${limit.file__x3A__open_file.if_exceeded}
  94. will sleeping 5 seconds..
  95. </echo>
  96. <sleep seconds="1"/>
  97. <echo>....5</echo>
  98. <sleep seconds="1"/>
  99. <echo>....4</echo>
  100. <sleep seconds="1"/>
  101. <echo>....3</echo>
  102. <sleep seconds="1"/>
  103. <echo>....2</echo>
  104. <sleep seconds="1"/>
  105. <echo>....1</echo>
  106. <sleep seconds="1"/>
  107. <echo>....0</echo>
  108. </target>
  109. <extension-point name="say_and_describe_file" depends="say_and_describe_file__x3A__controller" description="to just describe file size and say its contents"/>
  110. <extension-point name="say_and_describe_file__x3A__controller" depends="say_and_open_file.input,
  111. limit.file.size__x3A__open_file.if_not_exists,
  112. describe_file__x3A__size,
  113. say_and_describe_file.warning,
  114. say_and_open_file.action,
  115. say_and_open_file.drop_overflow.action" />
  116. <target name="say_and_describe_file.warning" if="describe_file__x3A__size__x3A__warning_flag">
  117. <property name="local.p5apl.terminal-notifier.message" value="Uwaga nieoczekiwana wielkośc pliku ${local.p5ant.safety.filename} "/>
  118. <property name="local.p5apl.terminal-notifier.title" value="wytworzonego pliku "/>
  119. <property name="local.p5apl.terminal-notifier.subtitle" value=" wielkość ${local.p5ant.safety.filename.length}"/>
  120. <ant antfile="${p5suis.build}" target="p5suis:say_to_queue.PL">
  121. <property name="p5suis:say_text" value="${local.p5apl.terminal-notifier.message} ${local.p5apl.terminal-notifier.title} ${local.p5apl.terminal-notifier.subtitle}"/>
  122. </ant>
  123. <echo>#149 sayed [ W A R N I N G ] $describe_file__x3A__size__x3A__warning_flag ${describe_file__x3A__size__x3A__warning_flag}</echo>
  124. </target>
  125. <target name="describe_file__x3A__size" >
  126. <input addproperty="local.p5ant.safety.filename" message="local.p5ant.safety.filename type!"/>
  127. <input addproperty="local.p5ant.safety.limit.file.size__x3A__open_file.units" message="local.p5ant.safety.limit.file.size__x3A__open_file.units" defaultvalue="${p5ant.safety.limit.file.size__x3A__open_file.units}" />
  128. <input addproperty="local.p5ant.safety.limit.file.size__x3A__open_file" message="local.p5ant.safety.limit.file.size__x3A__open_file" defaultvalue="${p5ant.safety.limit.file.size__x3A__open_file}"/>
  129. <fileset id="describe_file__x3A__size.if_exceeded.fileset" file="${local.p5ant.safety.filename}">
  130. <size value="${local.p5ant.safety.limit.file.size__x3A__open_file}" units="${local.p5ant.safety.limit.file.size__x3A__open_file.units}" when="more"/>
  131. </fileset>
  132. <property name="describe_file__x3A__size.if_exceeded.fileset" refid="describe_file__x3A__size.if_exceeded.fileset"/>
  133. <length property="local.p5ant.safety.filename.length" file="${local.p5ant.safety.filename}" />
  134. <condition property="describe_file__x3A__size.if_exceeded" value="is exceeded file : ${describe_file__x3A__size.if_exceeded.fileset} ">
  135. <!--<istrue value="${local.p5ant.safety.filename.length}"/>-->
  136. <and>
  137. <contains string="${local.p5ant.safety.filename}" substring="${describe_file__x3A__size.if_exceeded.fileset}"/>
  138. <not>
  139. <equals arg1="${limit.file.size__x3A__open_file.if_exceeded.fileset}" arg2="" />
  140. </not>
  141. </and>
  142. <!--<isset property="limit.file.size__x3A__open_file.if_exceeded.fileset"/>-->
  143. </condition>
  144. <condition property="describe_file__x3A__size__x3A__warning_flag" value="is exceeded file : ${describe_file__x3A__size.if_exceeded.fileset}">
  145. <and>
  146. <contains string="${local.p5ant.safety.filename}" substring="${describe_file__x3A__size.if_exceeded.fileset}"/>
  147. <not>
  148. <equals arg1="${describe_file__x3A__size.if_exceeded.fileset}" arg2="" />
  149. </not>
  150. </and>
  151. </condition>
  152. <echo> #17- [? C O N D I T I O N ?] results:
  153. [ $describe_file__x3A__size.if_exceeded = ${describe_file__x3A__size.if_exceeded} ]
  154. [ $local.p5ant.safety.limit.file.size__x3A__open_file.units = ${local.p5ant.safety.limit.file.size__x3A__open_file.units} ]
  155. [ $describe_file__x3A__size.if_exceeded.fileset = ${describe_file__x3A__size.if_exceeded.fileset} ]
  156. [ $describe_file__x3A__size__x3A__warning_flag = ${describe_file__x3A__size__x3A__warning_flag} ]
  157. [ $local.p5apl.terminal-notifier.group = ${local.p5apl.terminal-notifier.group} ] - nice to set!!!
  158. </echo>
  159. </target>
  160. <extension-point name="say_and_open_file" depends="say_and_open_file.input, open_file" />
  161. <extension-point name="say_and_open_file.drop_overflow" depends="say_and_open_file.drop_overflow.input, open_file"/>
  162. <target name="say_and_open_file.input">
  163. <property name="local.say_and_open_file" value="open and say "/>
  164. <echo>+ [ $local.say_and_open_file = ${local.say_and_open_file} ]</echo>
  165. </target>
  166. <target name="say_and_open_file.drop_overflow.input">
  167. <property name="local.say_and_open_file.drop_overflow" value="open and say with drop overflow"/>
  168. <echo>+ [ $local.say_and_open_file.drop_overflow = ${local.say_and_open_file.drop_overflow} ]</echo>
  169. </target>
  170. <target name="say_and_open_file.action" if="local.say_and_open_file" unless="limit.file.size__x3A__open_file__x3A__deny_flag" >
  171. <ant antfile="${p5suis.build}" target="p5suis.say_to_queue.copy_file">
  172. <property name="p5suis.say_to_queue.copy_file" value="${local.p5ant.safety.filename}"/>
  173. </ant>
  174. </target>
  175. <target name="say_and_open_file.drop_overflow.action" if="local.say_and_open_file.drop_overflow" unless="limit.file.size__x3A__open_file__x3A__deny_flag" >
  176. <echo>#121 + [ c o p y o v e r f l o w s a y ] </echo>
  177. <ant antfile="${p5suis.build}" target="p5suis.say_to_queue.copy_file.drop_overflow">
  178. <property name="p5suis.say_to_queue.copy_file" value="${local.p5ant.safety.filename}"/>
  179. </ant>
  180. </target>
  181. <target name="open_file__x3A__opened" if="open_file__x3A__opened">
  182. <echo level="info">#128-166 [ O P E N F I L E ] [ O K ] controller $open_file__x3A__opened = ${open_file__x3A__opened}
  183. </echo>
  184. </target>
  185. <target name="open_file__x3A__error" unless="open_file__x3A__opened">
  186. <echo level="error">#128 there is not aviable any function to UI open file -
  187. $open_file__x3A__opened ${open_file__x3A__opened}
  188. [ open_file__x3A__p5apl.terminal-notifier ]
  189. [ open_file__x3A__p5apl.open ]
  190. </echo>
  191. </target>
  192. <extension-point name="open_file__x3A__p5apl.open" />
  193. <extension-point name="open_file__x3A__p5apl.terminal-notifier" />
  194. <extension-point name="open_file" unless="limit.file.size__x3A__open_file__x3A__deny_flag" description="to safe open file when it not exceeds $p5ant.safety.limit.file.size__x3A__open_file"
  195. depends="open_file.input,
  196. limit.file.size__x3A__open_file.if_not_exists,
  197. limit.file.size__x3A__open_file.if_exceeded,
  198. limit.file.size__x3A__open_file.rename,
  199. limit.file.size__x3A__open_file.notify,
  200. limit__x3A__open_file.sleep,
  201. say_and_open_file.action,
  202. say_and_open_file.drop_overflow.action,
  203. limit.file.size__x3A__open_file.message,
  204. open_file__x3A__p5apl.terminal-notifier,
  205. open_file__x3A__p5apl.open,
  206. open_file__x3A__error,
  207. open_file__x3A__opened
  208. "/>
  209. <target name="limit.file.size__x3A__open_file.message" unless="limit.file.size__x3A__open_file__x3A__deny_flag" description="to safe open file when it not exceeds $p5ant.safety.limit.file.size__x3A__open_file">
  210. <basename property="local.p5ant.safety.filename.basename" file="${local.p5ant.safety.filename}"/>
  211. <property name="local.p5apl.terminal-notifier.message" value="otworz plik ${local.p5ant.safety.filename.basename} "/>
  212. <property name="local.p5apl.terminal-notifier.title" value="plik gotowy do otwarcia"/>
  213. <property name="local.p5apl.terminal-notifier.subtitle" value="kliknij na link"/>
  214. <echo level="info">#18 [ S A F E O P E N F I L E ] = [== F I L E I S S A F E T O O P E N ==]=
  215. LIMIT $local.p5ant.safety.filename.length = ${local.p5ant.safety.filename.length} tested against ${local.p5ant.safety.limit.file.size__x3A__open_file} ($local.p5ant.safety.limit.file.size__x3A__open_file)
  216. RESULT $local.p5ant.safety.filename = ${local.p5ant.safety.filename}
  217. $local.p5ant.safety.filename.length = ${local.p5ant.safety.filename.length}
  218. $limit.file.size__x3A__open_file.if_exceeded ${limit.file.size__x3A__open_file.if_exceeded}
  219. + $local.p5apl.terminal-notifier.message = ${local.p5apl.terminal-notifier.message}
  220. </echo>
  221. <ant antfile="${p5suis.build}" target="p5suis:say_to_queue.PL.drop_overflow">
  222. <property name="p5suis:say_text" value=" gotowy do otwarcia plik p5:file ${local.p5ant.safety.filename} o oczekiwanej p5:size ${local.p5ant.safety.filename.length} , mniejszej od limitu p5:size__x3A__unit ${local.p5ant.safety.limit.file.size__x3A__open_file}__x3A__${local.p5ant.safety.limit.file.size__x3A__open_file.units} . "/>
  223. </ant>
  224. <!--<exec executable="open">
  225. <arg file="${local.p5ant.safety.filename}"/>
  226. </exec>-->
  227. </target>
  228. <target name="antcall" description="to get some notifications about task finished or not finished ">
  229. <description>will use properties and if not success ge wont set some flag - thus ntoficiation will occur</description>
  230. <input addproperty="local.ant.safety.task.complete.output" message="local.ant.safety.task.complete.output" defaultvalue="local.ant.safety.task.complete.output"/>
  231. <tempfile id="local.ant.safety.output__analyze.temp" property="local.ant.safety.output__analyze.temp" prefix="local.ant.safety.output__analyze.temp" suffix="log"/>
  232. <echo> #2444 try to look at $local.ant.safety.task.complete.output ${local.ant.safety.task.complete.output} and parse? </echo>
  233. </target>
  234. <extension-point name="open_dir" description="to verify dir exists or error messages"
  235. depends="open_dir.input , open_dir.if_not_exists, open_dir.if_not_exists.error , say_and_open_dir, p5apl.terminal-notifier.notify"
  236. />
  237. <target name="open_dir.input">
  238. <input addproperty="local.p5ant.safety.filename" message="local.p5ant.safety.filename - dir " />
  239. <property name="local.p5apl.terminal-notifier.open" value="${local.p5ant.safety.filename}"/>
  240. </target>
  241. <target name="open_dir.if_not_exists">
  242. <condition property="open_dir.if_not_exists">
  243. <not><available file="${local.p5ant.safety.filename}"></available></not>
  244. </condition>
  245. </target>
  246. <target name="open_dir.if_not_exists.error" if="open_dir.if_not_exists">
  247. <echo>#245 [ N O T I F Y ] $open_dir.if_not_exists ${open_dir.if_not_exists} </echo>
  248. <property name="local.p5apl.terminal-notifier.message" value="oczekiwany katalog nie istnieje"/>
  249. <property name="local.p5apl.terminal-notifier.title" value="p5ant.open_dir"/>
  250. <property name="local.p5apl.terminal-notifier.subtitle" value="dir not exists"/>
  251. <ant antfile="${p5suis.build}" target="p5suis:say_to_queue.PL">
  252. <property name="p5suis:say_text" value="Oczekiwany katalog p5:file ${open_dir.if_not_exists} nie istnieje."/>
  253. </ant>
  254. </target>
  255. <target name="say_and_open_dir" unless="open_dir.if_not_exists" >
  256. <echo>#245-OK [ N O T I F Y ] ready to open dir ${local.p5ant.safety.filename} </echo>
  257. <ant antfile="${p5suis.build}" target="p5suis:say_to_queue.PL">
  258. <property name="p5suis:say_text" value="Oczekiwany katalog p5:file ${open_dir.if_not_exists} gotowy do otwarcia."/>
  259. </ant>
  260. <property name="local.p5apl.terminal-notifier.message" value="akcja otwarcia katalogu możliwa"/>
  261. <property name="local.p5apl.terminal-notifier.title" value="p5ant.open_dir"/>
  262. <property name="local.p5apl.terminal-notifier.subtitle" value="OK dir exists ;-)"/>
  263. </target>
  264. </project>