设为首页 收藏本站
查看: 392|回复: 0

[经验分享] Python on iPhone actually rather good

[复制链接]

尚未签到

发表于 2017-4-29 15:05:22 | 显示全部楼层 |阅读模式
  Python Nutter    Posts: n/a
#1: Nov 4 '08 
 
Mini install guide for python on the iPhone:
  Cydia =Install SSH helps make initial configuration easier until you
get used to MobileTerminal
Cydia =Install MobileTerminal (closest to a bash shell you get on
your iPhone currently)
Cydia =Install Finder (graphical alternative to using
SSH/MobileTerminal for setting permissions, navigating file system,
moving/copying files, etc.)
Cydia =Install Python (currently installs CPython 2.5.1)
Cydia =Install PyObjC (this is your hook into iPhone API)
Cydia =Install Setuptools (currently install 0.6c7)
Cydia =Install iPhone/Python (examples, the hello world is a PyObjC
call into the iPhone API to load and scroll the contacts list in the
phone)
  Not much left to have a fast running python implementation in your
pocket except IMHO ipython. Now that you have Setuptools installed,
you can run easy_install directly on your iPhone and download iPython
over the air.
  The iPhone OS X architecture is of course a BSD Unix Userland
environment so you should feel right at home.
  The two accounts, root and mobile both share the same default password
'alpine'. So once you setup your phone I recommend you change the
password for each account right away just to secure your phone a
little more. Root you won't need, Mobile is what the default account
is on the current iPhone OS implementation for the standard user
(you).
  Easiest way to access your phone is SSH from your Mac, Linux, or
Windows box. (or just use MobileTerminal.app on the iphone directly
keeping in mind you will default to the mobile account in the shell)
Simply join your iPhone over wifi to your wireless access point or
ad-hoc-network, and display your iPhone's ip address. Now you are
ready to ssh into it.
$ssh root@<your iphones ip address>
password: alpine
$chpass
<change your password for root>
while you are here might as well install ipython
$easy_install ipython
$exit
  now same for mobile
$ssh root@<your iphone ip address>
password: alpine
$chpass
<change your password for mobile>
  $ipython
<test your ipython if it loads, yes? good. now just exit()>
  $cd .ipython
$nano ipy_user_conf.py
<or vi or emac or whatever you like, its easier for beginners to try nano>
  CTRL+W (find)
Where: #import ipy_editors
<Now for those who are following along using MobileTerminal.app here
is a quick guesture routine
Single Tap screen to bring up a quick tap box grid of common unix
commands that get pasted when selected into the shell
Double Tap screen to hide the onscreen keyboard and see the full screen.
Drag Top left downward diagonally to right for CTRL
Drag Top right downward diagonally to left for TAB -- good for tab
completion in the bash shell
  <ok back to editing ipy_user_conf.py>
Delete the # comment character
  Scroll down <MobileTerminal.app users just drag up, down, left, or
right quickly for cursor movement>
  Add your new line below the text "# Or roll your own"
ipy_editors.install_editors("nano +$line $file")
  CTRL+X (exit)
Y to save
  Now test your ipython link to nano editor
$ipython
In [1]: edit test.py
<nano should now launch and you can edit your python script on your
iPhone directly, when you save it, iPython will execute the python
code>
In [2]: exit()
$cat test.py
<your code should display, good now we are done>
$rm test.py <remove our test file>
  Its up to you where you want to save your python scripts. I would
suggest in Documents under your account (mobile).
<for example launch MobileTermina.app>
$cd ~
$cd D* <or just D and try the tab completion gesture Top right
drag diagonally down to left>
$mkdir python <or whatever you want to call your directory>
  
What is missing? Tkinter, iPhone uses its own API, Desktop Manager
(Springboard), etc.
What is different? PyObjC, this is where you get to use those iPhone
API calls from within your python script on the iPhone including GUI
API calls.
  Now you have Python in your Pocket that you can take anywhere and whip
it out anytime the Python bug hits you and you want to work on some
code.
  You can use SSH to move/copy/sync your files to your desktop.
Or other ways: AirSharing app over wifi, etc.
  I'll be giving iPhone Python 2.5.1 a workout on on of Mark Lutz's
books and report any more gotchas that I come across.
  Cheers,
PN

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-370910-1-1.html 上篇帖子: python安全管理子进程-subprocess 下篇帖子: Windows下的VIM搭建Python
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表